Pruteanu Alexandru
Pruteanu Alexandru

Reputation: 33

Option tag - open page in the same tab

I this case how to open the page in the same tab???

<html>
<head>
</head>
<body>
<select name="menu1" id="menu1">
<option value="http://www.espn.com">ESPN</option>
<option value="http://www.cnn.com">CNN</option>
<option value="http://www.abcnews.com">ABC</option>
<option value="http://www.cbsnews.com">CBS</option>
<option value="http://www.foxnews.com">FOX</option>
</select>
<script type="text/javascript">
 var urlmenu = document.getElementById( 'menu1' );
 urlmenu.onchange = function() {
      window.open( this.options[ this.selectedIndex ].value );
 };
</script>
</body>
</html>

I must to open three diferit page in the same tab I find this on the internet but I don't know how to change the code to open page the same page.

Upvotes: 0

Views: 42

Answers (2)

J.O.L.
J.O.L.

Reputation: 153

If you want to navigate to that address in the current tab, just set the value of window.location:

window.location = this.options[this.selectedIndex].value;

Upvotes: 1

Entcraft44
Entcraft44

Reputation: 84

Try using window.open( this.options[ this.selectedIndex ].value, "_self" );

Upvotes: 0

Related Questions