homepage Welcome to WebmasterWorld Guest from 54.161.240.10
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
IFRAMEs, JavaScript, ASP
Help wanted: How to reload 2 iframes with one click
ondfisk




msg:1480741
 4:51 am on Apr 5, 2002 (gmt 0)

Hi!
I have a problem with a new website I'm developing.

I have a page with say two iframes...

<html>
<head>Problem</head>
<body>
<a href=newpage.htm target=_contents>Newpage</a>

<h1>Iframe1</h1>
<iframe src=banner.asp>

<h1>Iframe2</h2>
<iframe src=content.asp target=_contents>

</body>
</html>

Now, I want to be able to click on a link in either the body or in _contents-iframe and then reload banner.asp while loading a new document for the iframe.

Hope you guys can help me out

 

tedster




msg:1480742
 6:24 am on Apr 5, 2002 (gmt 0)

Ondfisk, welcome to the boards! This is script I use to change 2 frames from one link. Never tried it with iFrames but I think it should work. Since each iFrame is contained as a window object in the window.frames, it should convert just fine.

First
When you set up each iframe, give it a name - let's use "banner" and "content".

Next
Define the following function in the HEAD or external js file:

function loadFrames(page1,page2) {
eval("window.frames.banner.location='"+page1+"'");
eval("window.frames.content.location='"+page2+"'");
}

Finally
Code the links into the main page:

<p><a href="javascript:loadFrames('banner1.asp','content1.asp')">Load Combo #1</a>

<p><a href="javascript:loadFrames('banner2.asp','content2.asp')">Load Combo #2</a>

etc.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved