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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christian Radermacher

    [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.creat eElement("a");
    a.innerHTML = "anchor "+i;
    a.setAttribute( "innerHTML" , "anchor "+i);
    a.setAttribute( "href", "javascript:par ent.h_click()") ;
    window.frames[0].document.body. appendChild(a);
    }
    }
    function h_click() {
    alert('ciao!');
    }
    </script>
    </head>
    <body>
    <input type="button"
    onclick="docume nt.body.appendC hild(document.c reateElement('i frame'))"
    value="new iFrame">
    <input type="button" onclick="newA() " value="new anchor">
    </body>
    </html>


    The same stuff adapted to IE6 works.

    Suggestions?

    Thnx,

    Christian

  • Grant Wagner

    #2
    Re: [Netscape] href in iframe hangs when calling function in parentwindow

    Christian Radermacher wrote:
    [color=blue]
    > 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.creat eElement("a");
    > a.innerHTML = "anchor "+i;
    > a.setAttribute( "innerHTML" , "anchor "+i);
    > a.setAttribute( "href", "javascript:par ent.h_click()") ;
    > window.frames[0].document.body. appendChild(a);
    > }
    > }
    > function h_click() {
    > alert('ciao!');
    > }
    > </script>
    > </head>
    > <body>
    > <input type="button"
    > onclick="docume nt.body.appendC hild(document.c reateElement('i frame'))"
    > value="new iFrame">
    > <input type="button" onclick="newA() " value="new anchor">
    > </body>
    > </html>
    >
    > The same stuff adapted to IE6 works.
    >
    > Suggestions?
    >
    > Thnx,
    >
    > Christian[/color]

    <script type="text/javascript">
    function newA() {
    for (i=0;i<3;i++) {
    var a = window.frames[0].document.creat eElement("a");
    var t = window.frames[0].document.creat eTextNode("anch or" + 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 <gwagner@agrico reunited.com>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    *


    * Internet Explorer DOM Reference available at:
    *
    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


    * 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


    Comment

    Working...