/    Sign up×
Community /Pin to ProfileBookmark

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: [URL=”http://sosimagesonline.com/testing/linkpage”]http://sosimagesonline.com/testing/linkpage[/URL]

[code=html]<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>
[/code]

[code=html]<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>
[/code]

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.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Sterling_IsfineSep 05.2009 — 
[code=html]
<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" [/code]
[/QUOTE]
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 '='.
Copy linkTweet thisAlerts:
@lastlifelostauthorSep 06.2009 — 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?
×

Success!

Help @lastlifelost spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...