/    Sign up×
Community /Pin to ProfileBookmark

URL’s, iFrames and JavaScript

Hi Guys,

I’m doing some work on a clients site that was developed using iFrames and I’m having a bit of an issue with getting external links to bring up the desired pages.

Eg. A mail out is sent to a group with a direct link to an individual page ([url]www.myurlxxx.commyotherpage.html[/url]) that appears within the main site ([url]www.myurlxxx.com[/url]) rather than just the page that’s within the iFrame loading.

I’m not familiar with iFrames so it may well be a simple thing to sort out but my initial thought was to use the script:

function direct(){
var url= (location.href);
var homepage= “homepage.html”;
var navigate= “http://www.myurlxxx.com“;
if (url == navigate)
{
document.getElementById(“mainWindow”).src = homepage;
}
else {
document.getElementById(“mainWindow”).src = url;
}

}

On page load, in order to parse the desired url into the src of the iFrame.

However whenever I try this I get errors when the else statement is called.

Anyone got any ideas……

Do I need to split the url so just the html page is loaded rather than the entire url?

Or am I going about this in an altogether too elaborate (or stupid) way and making things difficult for myself?

Any help would be appreciated as I feel like I’m going round in circles.

Thanks

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @SonicApe 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...