R
Ross
Hello all,
I'm having trouble with an appendChild() that works in Firefox and
Camino Browsers, but not in Safari. I"m on Mac OS X with Safari 4.0.4,
Camino 2.0 and Firefox 3.5.
I receive a separate xhtml-xml typed doc ("nuDoc") through an HTTP
GET, and parse it happily, extracting a certain div element. Then I
call the handy little Dom Routine (see below) to append the div
element from nuDoc into one ('pasteHere') in the existing webpage's
DOM. Simply...
alldivs = nuDoc.getElementsByTagName("div");
targetSpot = 'pasteHere'
Dom.add(alldivs[0], targetSpot);
In FF & Camino it works great and I see my two alert pop-ups.
First Alert says
Got these: [object HTMLDivElement] & [object HTMLDivElement]
Then I get Alert with "Progress: Append"
In Safari I get the first alert, with the same objects, so they are
being found, but the script crashes on the appendChild() and I don't
see the second alert.
Earlier in the script I did a successful add of a button using that
same Dom.add, but the button used innerHTML I created on the spot.
var Dom = {
get: function(el) {
if (typeof el === 'string') { //look it up if its a
string
return document.getElementById(el);
} else {
return el; //otherwise just send it
back
}
},
add: function(el, dest) {
var el = this.get(el);
var dest = this.get(dest);
alert("Got these: " + el + " & " + dest);
dest.appendChild(el);
alert("Progress: Append");
},
remove: function(el) {
var el = this.get(el);
el.parentNode.removeChild(el);
}};
Any suggestions?
Thanks
Ross.
I'm having trouble with an appendChild() that works in Firefox and
Camino Browsers, but not in Safari. I"m on Mac OS X with Safari 4.0.4,
Camino 2.0 and Firefox 3.5.
I receive a separate xhtml-xml typed doc ("nuDoc") through an HTTP
GET, and parse it happily, extracting a certain div element. Then I
call the handy little Dom Routine (see below) to append the div
element from nuDoc into one ('pasteHere') in the existing webpage's
DOM. Simply...
alldivs = nuDoc.getElementsByTagName("div");
targetSpot = 'pasteHere'
Dom.add(alldivs[0], targetSpot);
In FF & Camino it works great and I see my two alert pop-ups.
First Alert says
Got these: [object HTMLDivElement] & [object HTMLDivElement]
Then I get Alert with "Progress: Append"
In Safari I get the first alert, with the same objects, so they are
being found, but the script crashes on the appendChild() and I don't
see the second alert.
Earlier in the script I did a successful add of a button using that
same Dom.add, but the button used innerHTML I created on the spot.
var Dom = {
get: function(el) {
if (typeof el === 'string') { //look it up if its a
string
return document.getElementById(el);
} else {
return el; //otherwise just send it
back
}
},
add: function(el, dest) {
var el = this.get(el);
var dest = this.get(dest);
alert("Got these: " + el + " & " + dest);
dest.appendChild(el);
alert("Progress: Append");
},
remove: function(el) {
var el = this.get(el);
el.parentNode.removeChild(el);
}};
Any suggestions?
Thanks
Ross.