Results 1 to 2 of 2

Thread: frames on safari 3 does not work

  1. #1
    Join Date
    Nov 2005
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default frames on safari 3 does not work

    Hi,

    I have a frame that works on IE 7 but does not work on safari 3.
    It shows the message like this:

    TypeError: Value undefined (result of expression top.frames["toolbar"].doSomething2) is not object.

    Here is the code

    default.htm
    Code:
    <HTML>
    <frameset id="frameset1" rows="119,*" name="frameset1" border="0" frameSpacing="0" frameBorder="no">
            <frame name="toolbar" id="toolbar" src="button.htm" marginheight="0" marginwidth="0" scrolling="no" NORESIZE>
            <frame name="top_main" id="top_main" src="button2.htm" marginheight="0" marginwidth="0" NORESIZE>
        </frameset>
    </HTML>
    button.htm
    Code:
    <html>
    
    <head>
    <script>
    function doSomething2(){
                document.write("this is my document");
    }
    </script>
    </head>
    <body>
    my page
    </body>
    
    </html>
    button2.htm
    Code:
    <HTML>
    <script>
    try{
    
    top.frames["toolbar"].doSomething2()
    }
    catch(e){alert(e);}
    </script>
    <body>
    button2<br />
    </body>
    </HTML>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This is a comedy of errors.

    document.write overwrites a page. So, the moment doSomething2() begins to be invoked, it no longer exists, unless button.htm hasn't been fully parsed yet, or the browser just wants to allow it. In FF it 'works' but the frameset never completely loads. Opera doesn't like it at all, just like Safari. Only IE seems to be completely OK with it. On top of that, the markup is invalid, and Safari appears to not want to refer to a function in the frame from the frame's name or id, rather by its number:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
    <html>
    <head>
    <title>Conforming HTML 4.01 Transitional Template</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <frameset id="frameset1" rows="119,*">
            <frame name="toolbar" id="toolbar" src="button.htm" scrolling="no" frameborder="0" noresize>
            <frame name="top_main" id="top_main" src="button2.htm" frameborder="0" noresize>
    <noframes>
    <body>
    <!-- place alternative information for accessibility purposes here -->
    </body>
    </noframes>
    </frameset>
    </html>
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    body {
    margin:0;
    padding:0;
    }
    </style>
    </head>
    <body>
    <div id="txt">my page</div>
    <script type="text/javascript">
    function doSomething2(){
    var t=document.getElementById('txt');
    t.replaceChild(document.createTextNode('this is my document'), t.firstChild);
    };
    </script>
    </body>
    </html>
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    body {
    margin:0;
    padding:0;
    }
    </style>
    <script type="text/javascript">
    try{
    top.frames['toolbar'].doSomething2();
    }catch(e){
    try{
    for ( var i = top.frames.length-1; i > -1; --i)
    if(top.frames[i].name=='toolbar')
    break;
    top.frames[i].doSomething2();
    }catch(e){alert(e);};
    };
    </script>
    </head>
    <body>
    button2<br>
    </body>
    </html>
    Last edited by jscheuer1; 01-17-2008 at 09:25 AM. Reason: spelling
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •