Click to See Complete Forum and Search --> : beginner window.open question


madmartini
02-16-2003, 08:46 PM
I am having trouble getting the window.open function to open a url in the current window.


window.open(retURL,'newWindow','location=no,menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes');

I have a function that feeds in a retURL. I want that URL to be loaded in the current window. I have tried using _self or _top instead of 'newWindow' but that doesnt work. I have tried naming the current window 'newWindow' but that didnt work either.

This is easy huh?
Thanks in advance for any help
Newbie

2 peachy
02-16-2003, 09:05 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Example</title>

<script>
function Go()
{
//reference to the list
var mList = document.myform.URLs;

//selected URL
var url = mList.options[mList.selectedIndex].value;

//jump to specified link
window.location.href = url;
}
</script>

</head>

<body>
<form name="myform">
<select name="URLs" size=1 onChange="Go()">
<option value="http://www.yahoo.com">Yahoo
<option value="http://www.cnet.com">CNet
<option value="http://www.tucows.com">TuCows
<option value="http://www.cnn.com">CNN
</select>
<input type="button" value="Go"
onClick="Go()">
</form>
</body>
</html>

try this... edit as needed

madmartini
02-24-2003, 05:00 PM
Cool thanks peachy.

I got window.location.href = url;
to work by using onClick instead of onSubmit for my form button.

Thanks for the nudge in the right direction!

mm