Click to See Complete Forum and Search --> : Multiloading


raider
12-02-2003, 08:31 AM
Hi guys, I'm in the need for a script which when a link is activated, it changes a document in an IFRAME, AND changes an "image" on the same page where the link is at.

The design of the page, has a space above the IFRAME, and a menu beneath the IFRAME. When clicking on a link in the menu, the titlte ("image" place in the space above the IFRAME) changes and the page inside the IFRAME changes.

Is this possible, and could somebody help me with this problem?

ray326
12-02-2003, 11:18 AM
In the onclick handler for that menu item just change the src of the iframe and the src for the img. Give each an id and use document.getElementById() to access them.

raider
12-02-2003, 01:01 PM
Hi, could you please specify the scriptcode. Can't find where to place it another code I have.

Thanks... :)

ray326
12-02-2003, 02:01 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>img/iframe demo</title>
</head>
<style type="text/css">
img {display: block;}
</style>
<script language="Javascript">
function setsource(image, loc)
{
document.getElementById("topimage").src=image;
document.getElementById("topframe").src=loc;
}
</script>
<body>

<img id="topimage" src="http://forums.webdeveloper.com/img/webdevlogoz.gif" />
<iframe id="topframe" src="http://www.webdeveloper.com/"></iframe>
<ul>
<li><a href='javascript:setsource("http://forums.webdeveloper.com/img/webdevlogoz.gif","http://www.webdeveloper.com/")'>WebDeveloper</a></li>
<li><a href='javascript:setsource("http://developer.java.sun.com/images/v4_java_logo.gif","http://developer.java.sun.com/")'>Java Developer Connection</a></li>
</ul>
</body>
</html>

NOTE: this BBS has munged the above code. In the href it should be javascript not java script! :mad:

raider
12-02-2003, 02:43 PM
Thanks again, ray326. The code looks correct, but when the link is activated, it returns a blank page.

I've inserted the code in my website, I you want to take a look.

http://www.geocities.com/divineyeti/

ray326
12-02-2003, 02:51 PM
For some reason this stupid BBS munged the code when I pasted it in. Replace java script with javascript and it will work as advertised.

raider
12-02-2003, 03:04 PM
Seems to work now, thank you very much. Saved my day ;)