Log in

View Full Version : Drop Down Box within iframe



mstolton
07-05-2008, 06:13 PM
I have a drop down box within an iframe. I would like it so that when the drop down box is used the entire page loads outside the borders of the iframe and the iframe disappears. I've been trying to change the below code but no luck whatsoever?! Is there anyone clever enough and kind enough out there to amend my below code, it would be a great help!!

<form name="jumpy">
<p><select style="width:350px" name="example" size="1" onChange="gone()">
<option value="">Select</option>
<option value=""></option>
<option value="http://www.google.com">Google</option>
<option value="http://www.yahoo.com">Yahoo</option>
<option value="http://www.altavista.com">Alta Vista</option>
</select>
<script language="javascript">
<!--

/*Jumpy combo box credit:
JavaScript Kit (www.javascriptkit.com)
Over 200+ free JavaScripts here!
*/

function gone()
{
location=document.jumpy.example.options[document.jumpy.example.selectedIndex].value
}
//-->
</script>
</p>
</form>

magicyte
07-07-2008, 07:09 PM
Simple. Here is some code for the outer page:


<html>
<head>
<title>
</title>
<script language="JavaScript">
setInterval("check_for_change()", 100);

function check_for_change()
{
if(iframe.document.jumpy.example.selectedIndex==2)
{
window.location="http://www.google.com";
}
if(iframe.document.jumpy.example.selectedIndex==3)
{
window.location="http://www.yahoo.com";
}
if(iframe.document.jumpy.example.selectedIndex==4)
{
window.location="http://www.altavista.com";
}
}
</script>
</head>
<body>
<iframe src="your_src.html" name="ifram" id="ifram" width="500" >SORRY! IFRAMES DON'T WORK IN YOUR INTERNET BROWSER!</iframe>
</body>
</html>

That should do it.

-magicyte

Minos
07-09-2008, 10:52 AM
It should, but rather than add all that code, try changing:



location=document.jumpy.example.options[document.jumpy.example.selectedIndex].value


to:



top.location=document.jumpy.example.options[document.jumpy.example.selectedIndex].value


Alternatively, using parent in place of top would work, but only if you aren't nesting frames inside of each other.

mstolton
07-09-2008, 10:06 PM
Thanks for this! they both work. Cheers!

magicyte
07-10-2008, 05:08 PM
Hey, Minos, I make a living off of my OWN code. I don't change other people's code.

-magicyte

Minos
07-11-2008, 01:00 AM
Hey, Minos, I make a living off of my OWN code. I don't change other people's code.


Is there anyone clever enough and kind enough out there to amend my below code, it would be a great help!!


Make your living however you want, I did what the OP asked. There's no need to flame someone who has a more succinct, and still correct, answer.

magicyte
08-29-2008, 09:53 PM
Make your living however you want, I did what the OP asked. There's no need to flame someone who has a more succinct, and still correct, answer.

Sorry for my ignorant action...

-magicyte

P.S. :(:)

magicyte
08-29-2008, 09:54 PM
Hey, Minos, I make a living off of my OWN code. I don't change other people's code.

-magicyte

Quite stupid of me.

-magicyte