/    Sign up×
Community /Pin to ProfileBookmark

why using node in DOM has problem in IE but not in FireFox?

What’s wrong with the following code? It shows nothing in IE but working fine in FireFox. Is there another way to get around with it?

[CODE]
<script type=”text/javascript” src=”library/control.js?”></script>
<script language=”JavaScript” type=”text/javascript”>
<!–
function runonload(){
refreshCart(); //in control.js
tnode = document.createElement(“a”);
tnode.setAttribute(“href”, “index3e3.php”);
tnode.setAttribute(“target”, “mainFrame”);
tnode.appendChild(document.createTextNode(“oooo3otto”));
ele = parent.mapFrame.document.getElementById(“map”);
while (ele.hasChildNodes()){
ele.removeChild(ele.lastChild);
}
ele.appendChild(tnode);
}
//–>
</script>
<link rel=”stylesheet” href=”library/computek.css” type=”text/css” />
<title>Untitled Document</title>
</head>
<body onload=”runonload()”>
[/CODE]

Brendan?

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzOct 15.2005 — Try using dot syntax instead of setAttribute().

You could also try appending the text node after you append the link to #map.
Copy linkTweet thisAlerts:
@KeymoneOct 16.2005 — instead

tnode.setAttribute("href", "index3e3.php");

tnode.setAttribute("target", "mainFrame");

try

tnode.href="index3e3.php";

tnode.target="mainFrame";

but this wont work in FF ?

just make some browser detection
Copy linkTweet thisAlerts:
@FangOct 16.2005 — There's nothing wrong with adding the anchor with this DOM method in IE!

Look for the problem in refreshCart() or perhaps using the onload handler twice.
Copy linkTweet thisAlerts:
@ccp999authorOct 17.2005 — Even I changed it to the dot form as followed, IE still display nothing!
<i>
</i>function runonload(){
tnode = document.createElement("a");
tnode.href = "index3e3.php";
tnode.target = "mainFrame";
tnode.appendChild(document.createTextNode("oooo3otto"));
ele = parent.mapFrame.document.getElementById("map");
while (ele.hasChildNodes()){
ele.removeChild(ele.lastChild);
}
ele.appendChild(tnode);
}


In FF, everthing is still working perfectly!
Copy linkTweet thisAlerts:
@KravvitzOct 17.2005 — Have you made sure that IE is correctly accessing the frame?
Copy linkTweet thisAlerts:
@ccp999authorOct 17.2005 — IE gave me an error notice which said that on the line:

" ele.appendChild(tnode);"

at char 2 has "Invalid argument" with "Code 0".

I'm sure IE is correctly accessing the frame.

Brendan
Copy linkTweet thisAlerts:
@KravvitzOct 17.2005 — Hmm... Have you tried appending the text node to tnode after you appended tnode to ele?
Copy linkTweet thisAlerts:
@ccp999authorOct 17.2005 — Hey, it works after I put "parent.mapFrame" on everthing. Thanks all of you!
×

Success!

Help @ccp999 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...