PDA

View Full Version : Changing 2 Iframes with 1 hyperlinked picture



Marslauncher
11-22-2004, 01:21 PM
Ok I have a website where I use two Iframes, One Iframe selects a product, the other Iframe brings up the fabric selection, I want to be able to use a picture of a product category to change both Iframe 1 and Iframe 2.

I am very Java Unsavvy so if someone could help me out with both the eg

"Picture :) (onClick .... Do procedure double hyperlink)"

Refers to the Javascript Function that says

"Doublehyperlink = Iframe1 = blah.html and Iframe 2 = blah2.html"

You see what I mean? I know what it should do but I dont know how to put that into Javascript


Thanks in advance

John

magicyte
07-08-2008, 06:33 PM
easy. don't do a hyperlink. use onClick. onclick="function1tochange();function2tochange();".

-magicyte

Minos
07-09-2008, 11:05 AM
A quick script:



function linkr(){
document.frames["iframe1"].location.href = "./something.html"
document.frames["iframe2"].location.href = "./somethingelse.html"
}


A quick example:



<img src="myImage.jpg" alt="My PICTURE!" onClick="linkr()"/>


Keep in mind that depending on the names of the pages you are redirecting to, that one function could become a lot more powerful with a few modifications. For instance, let's say you have a picture of a hotdog. Iframe1 goes to hotdog.html, iframe2 goes to hotdogInfo.html.



function linkr(whereTo){
document.frames["iframe1"].location.href = "./" + whereTo + ".html"
document.frames["iframe2"].location.href = "./" + whereTo + "info.html"
}




<img src="myImage.jpg" alt="My PICTURE!" onClick="linkr('hotdog')"/>


Then, you could add a picture of a hamburger, and link to "hamburger.html" and "hamburgerinfo.html" by only changing that image's "linkr('hamburger')". Just depends what your overall goal is.