用window.open _self点击Onclick

时间:2014-08-29 18:49:20

标签: javascript

基本上只是试图让这个表单使用onclick来打开当前窗口中的链接...我想我会在window.open中使用_self选项但是我没有运气。

    <form data-theme="b" name="form21">
   <label style="font-size:18px; width:100%" data-theme="b" for="select-choice-1" class="select">Select your kennel's state:</label>
   <select name="menu" id="select-choice-1">
      <option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">Arizona</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">Arkansas</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">California</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">Maine</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">Michigan</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">Nebraska</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">New York</option>
   </select>
</form>
<button type="submit" data-theme="b" data-mini="true" class="ui-btn-hidden"  onClick="window.open(document.form21.menu.options[document.form21.menu.selectedIndex].value);"  aria-disabled="false">Go</button>

1 个答案:

答案 0 :(得分:0)

您应该使用location.href从您自己的页面重定向:

        <form data-theme="b" name="form21">
   <label style="font-size:18px; width:100%" data-theme="b" for="select-choice-1" class="select">Select your kennel's state:</label>
   <select name="menu" id="select-choice-1">
      <option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">Arizona</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">Arkansas</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">California</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">Maine</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">Michigan</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">Nebraska</option>
<option value="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">New York</option>
   </select>
</form>
<button type="submit" data-theme="b" data-mini="true" class="ui-btn-hidden"  onClick="location.href = document.form21.menu.options[document.form21.menu.selectedIndex].value;"  aria-disabled="false">Go</button>