Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
86
rated 0 times [  89] [ 3]  / answers: 1 / hits: 32613  / 11 Years ago, mon, december 23, 2013, 12:00:00
   <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 have this code and i want to open by click the selected in my page! not open another! thank you!


More From » jquery

 Answers
5

Use this :



urlmenu.onchange = function() {
window.open( this.options[ this.selectedIndex ].value, '_self');
};


window.open(URL,name,specs,replace):
where name:



_blank - URL is loaded into a new window. This is default
_parent - URL is loaded into the parent frame
_self - URL replaces the current page
_top - URL replaces any framesets that may be loaded
name - The name of the window (Note: the name does not specify the title of the new window)


DEMO Link


[#73582] Sunday, December 22, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
janjadonb

Total Points: 4
Total Questions: 114
Total Answers: 118

Location: Mali
Member since Fri, Dec 3, 2021
3 Years ago
janjadonb questions
;