www.webdeveloper.com
Results 1 to 3 of 3

Thread: Script only works in IE

  1. #1
    Join Date
    Aug 2009
    Posts
    10

    Script only works in IE

    I have this script that's working fine in IE, but seems to be breaking in Opera and FF. Below are the two pages involved. Can anyone see what's going on here?

    Working sample: http://sosimagesonline.com/testing/linkpage

    HTML Code:
    <head>
    	<title>	Page title	</title>
    </head>
    <body>
    <a href="framepage.htm?changeme= http://www.google.com" >Google</a>
    <a href="framepage.htm?changeme= http://sosimagesonline.com" >Sos Images Online</a>
    <a href="framepage.htm?changeme= http://www.2flashgames.com" >2flash</a>
    
    
    
    </body>
    </html>
    HTML Code:
    <head>
    <script language="JavaScript" type="text/javascript">
    function iframe_src() 
    { 
    var locsubstr = location.search.substring(1);//find url parameter 
    
    if((locsubstr.indexOf("changeme")!= -1))//if there is a new path for changeme 
    { 
    var changemeloc = locsubstr.substring(locsubstr.indexOf("=") + 1, locsubstr.length);//find the newpath for changeme 
    parent.frames[0].location.replace(changemeloc);//change changeme to new path 
    } 
    else 
    {parent.frames[0].location.replace(defaultpath);}//if there isn't a new path, set changeme to default 
    }
    </script>
    
    </head>
    <body onload = "iframe_src()";>
    <iframe src="default.htm" height="800" width="800" id="changeme" name="changeme"></iframe>
    </body>
    </html>
    What should happen is that the clicked link on the first page will open the second page with new content in the iframe, rather than the default iframe src.
    Last edited by lastlifelost; 09-05-2009 at 10:53 AM.

  2. #2
    Join Date
    Jun 2007
    Posts
    667
    Quote Originally Posted by lastlifelost View Post
    HTML Code:
    <a href="framepage.htm?changeme= http://www.google.com" >Google</a>
    <a href="framepage.htm?changeme= http://sosimagesonline.com" >Sos Images Online</a>
    <a href="framepage.htm?changeme= http://www.2flashgames.com"
    The URL being applied to the iframe consists of the original address followed by a space then the replacement.
    This is probably due to the space you specify after the '='.
    Y_U U_G_A_E_U_ B_S_A_D_

  3. #3
    Join Date
    Aug 2009
    Posts
    10
    Thanks so much for catching that, it works like a charm now! That's what I get for not reviewing the copy/paste code, right?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles