/    Sign up×
Community /Pin to ProfileBookmark

Reference an external Iframe

Hello everyone,

We have an HTML page which contains an Iframe where a specified HTML file will load. We would like to load a specific *.HTML into the Iframe based on a condition. This condition comes from a button pushed in our Flash movie and the variable is passed into Javascript.

In Javascript, here is the condition to load the main page (solutions.html):

if(linkobj==”somemovie1.flv”) {
location.href=”html/solutions/solutions.html”;
} else if (linkobj==”vid2.flv”) {

} else if (linkobj==”vid3.flv”) {

} else if (linkobj==”vid4.flv”) {

On the solutions.html page, our Iframe is defined as:
<iframe src=”page1.html” frameborder=”0″ name=”content” width=”850″ height=”410″ scrolling=”yes”></iframe>

I would like to have either page1.html, page2.html, page3.html load up based on a javascript condition.

I have so far tried:
window.main.frames[‘content’].location.replace(‘html/solutions/page1.html’);



frames.location.href=”html/solutions/page1.html”;


window.frames.content.location=”html/solutions/page1.html”;

document.write(“<iframe src=’html/solutions/page1.html’ frameborder=’0′ name=’content’ width=’850′ height=’410′ scrolling=’yes’>”);

//document.write(“</iframe>”);

Appreciate the help, and thank you in advance for your time.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JJan 11.2007 — Give the following a try


In solutions.html

function loadIframe(){

if (location.search.length > 0){

loc=unescape(location.search.substring(1))

window.frames["content"].location=loc

}

}

// add onload="loadIframe()" to the opening BODY tag



Your condition would then be

if(linkobj=="somemovie1.flv") {

location.href="html/solutions/solutions.html?page1.html";

} else if (linkobj=="vid2.flv") {

location.href="html/solutions/solutions.html?page2.html";


For an example see

www.huntingground.freeserve.co.uk/webplus/iframes/iframe_load6.htm
Copy linkTweet thisAlerts:
@AndanteauthorJan 15.2007 — Mr. J

I came back today and applied your solution.....works perfectly. Thank You for the help and the examples.
×

Success!

Help @Andante 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.19,
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,
)...