469,270 Members | 1,733 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

[Netscape] href in iframe hangs when calling function in parent window

Hi,

the following code has the mentioned behaviour:

<html>
<head>
<script type="text/javascript">
function newA() {
for (i=0;i<3;i++) {
var a = window.frames[0].document.createElement("a");
a.innerHTML = "anchor "+i;
a.setAttribute("innerHTML", "anchor "+i);
a.setAttribute("href", "javascript:parent.h_click()");
window.frames[0].document.body.appendChild(a);
}
}
function h_click() {
alert('ciao!');
}
</script>
</head>
<body>
<input type="button"
onclick="document.body.appendChild(document.create Element('iframe'))"
value="new iFrame">
<input type="button" onclick="newA()" value="new anchor">
</body>
</html>
The same stuff adapted to IE6 works.

Suggestions?

Thnx,

Christian

Jul 20 '05 #1
1 4151
Christian Radermacher wrote:
Hi,

the following code has the mentioned behaviour:

<html>
<head>
<script type="text/javascript">
function newA() {
for (i=0;i<3;i++) {
var a = window.frames[0].document.createElement("a");
a.innerHTML = "anchor "+i;
a.setAttribute("innerHTML", "anchor "+i);
a.setAttribute("href", "javascript:parent.h_click()");
window.frames[0].document.body.appendChild(a);
}
}
function h_click() {
alert('ciao!');
}
</script>
</head>
<body>
<input type="button"
onclick="document.body.appendChild(document.create Element('iframe'))"
value="new iFrame">
<input type="button" onclick="newA()" value="new anchor">
</body>
</html>

The same stuff adapted to IE6 works.

Suggestions?

Thnx,

Christian


<script type="text/javascript">
function newA() {
for (i=0;i<3;i++) {
var a = window.frames[0].document.createElement("a");
var t = window.frames[0].document.createTextNode("anchor" + i);
a.setAttribute("href", "#");
a.onclick = parent.h_click;
a.appendChild(t);
window.frames[0].document.body.appendChild(a);
}
}
function h_click() {
alert('ciao!');
return false;
}
</script>

Works in Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5b)
Gecko/20030904

Note that you shouldn't be setting HREF to "javascript:..." <url:
http://jibbering.com/faq/#FAQ4_24 /> and you should be returning false
from the onclick event.

Oddly enough, the links don't appear with the correct text decoration in
the version of Mozilla I tested it in. Nor does the mouse cursor change
when I roll over them. However, when clicked, they do alert "ciao!".

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Materialised | last post: by
4 posts views Thread by Peter Afonin | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.