Why my frame doesn't work on Safari 3.0.4?

Discussion in 'JavaScript' started by joecool2005, Feb 5, 2008.

  1. #1
    Hi,

    I want to build a simple frame.
    The following code works fine on IE6 and IE7 but doesn't work on Safari 3.0.4.
    It showed me this error message on Safari 3.0.4.
    Why?

    Plz help
    Thx
    Joe

    default.htm
    
    <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>
    
    Code (markup):
    button.htm
    
    <html>
    
    <head>
    <script language="JavaScript">
    function doSomething2(){
      alert("this is my document");
    }
    </script>
    </head>
    <body>
    my page
    </body>
    
    </html>
    
    Code (markup):
    button2.htm
    
    <HTML>
    <script language="JavaScript">
    try{
    
    top.frames["toolbar"].doSomething2()
    }
    catch(e){alert(e);}
    </script>
    <body>
    button2<br />
    </body>
    </HTML>
    
    Code (markup):
     
    joecool2005, Feb 5, 2008 IP
  2. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Here try this:

    button2.htm
    
    <HTML>
    <script language="JavaScript">
    try{
    document.getElementById('toolbar').contentWindow.doSomething2();
    }
    catch(e){alert(e);}
    </script>
    <body>
    button2<br />
    </body>
    </HTML>
    
    Code (markup):
     
    ToddMicheau, Feb 5, 2008 IP
  3. joecool2005

    joecool2005 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your help.

    I've tried it and it did not work

    On IE I see "[object Error]"
    On Safari 3.0.4 I see "TypeError: Null value"

    So this line is not good.
    document.getElementById('toolbar').contentWindow.doSomething2();

    Other suggestion?

    Thx
    Joe
     
    joecool2005, Feb 5, 2008 IP
  4. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Oops, I'm sorry, I should have tested that before posting. The only way I could get this running on Safari is to explicitly set the function:

    
    <html>
    <head>
    <script language="JavaScript">
    top.frames['toolbar'].doSomething = function(){
    alert("this is my document");
    };
    </script>
    </head>
    <body>
    my page
    </body>
    </html>
    
    Code (markup):
    Though this might now be feasible across site, it works. . . And is cross browser compatible.
     
    ToddMicheau, Feb 5, 2008 IP