PDA

View Full Version : Targeting Links



[lhomme]
March 25th, 2002, 19:44
How would I target the links in this dropdown menu to an iframe named "browser"?

<center><script language="JavaScript">
<!--
function goToURL(form)
{

var myindex=form.dropdownmenu.selectedIndex
if(!myindex=="")
{
window.location.href=form.dropdownmenu.options[myindex].value,;

// window.open(form.dropdownmenu.options[myindex].value,frameTarget,"");
}
}
//-->
</script>

<center>
<form name="dropDownForm">

<select name="dropdownmenu" size=1 onChange="goToURL(this.form)">
<option selected value="">Select a Resource
<option value="http://www.yahoo.com">Yahoo
</select>
</form></center>

Thanks.

Bruce
March 25th, 2002, 19:46
<form name="dropDownForm" target="browser">

[lhomme]
March 25th, 2002, 19:55
That doesn't seem to work, heres the rest of the page - whats wrong?

<center><script language="JavaScript">
<!--
function goToURL(form)
{

var myindex=form.dropdownmenu.selectedIndex
if(!myindex=="")
{
window.location.href=form.dropdownmenu.options[myindex].value,frameTarget,"browser";
}
}
//-->
</script>

<center>
<form name="dropDownForm" target="browser">

<select name="dropdownmenu" size=1 onChange="goToURL(this.form)">
<option selected value="">Select a Resource
<option value="http://www.yahoo.com">Yahoo
<option value="http://www.google.com">Google
<option value="http://www.your_main_website.com/your_page_3.htm">Page 3
<option value="http://www.your_main_website.com/your_page_4.htm">Page 4
<option value="http://www.your_main_website.com/your_page_5.htm">Page 5
</select>
</form></center>

<iframe src="guide.htm" border="1" width="600" height="500" marginwidth="0" marginheight="0" scrolling="auto" name="browser"></iframe>

meow
March 25th, 2002, 21:11
Not my thing but you have to use the names you've given the controls. Like dropDownForm not just "form".

It could probably be done better but here's a start:

<script type="text/javascript" language="javascript">
<!--

function goToURL(i)
{
var i = dropDownForm.dropdownmenu.selectedIndex;
if(i > 0)
{
window.document.browser.location.href=window.document.dropDo wnForm.dropdownmenu[i].value;
}
}

//-->
</script>

Dusty
March 25th, 2002, 21:17
window.location.href=...
Just change:

"window"

To:

"browser"

And you're set to go.

<edit>
And get rid of that ',frameTarget,"browser"' stuff, what is that supposed to be?
</edit>

[lhomme]
March 25th, 2002, 22:40
Thanks - its working now.