2 javascript forms text widget
这是我过去用于非wordpress网站的内容:
function goThere() {
var list = document.forms[0].articles
location = list.options[list.selectedIndex].value
}
Run Code Online (Sandbox Code Playgroud)
调用该函数的select元素:
<form>
<select id="articles" name="articles" onchange="goThere()">
<option value="#" selected>Choose an article</option>
<option value="document1.pdf">Document 1</option>
<option value="document2.pdf">Document 2</option>
<option value="document3.pdf">Document 3</option>
</form>
Run Code Online (Sandbox Code Playgroud)
您没有关闭您的选择标记.
你没有用分号结束你的javascript行.
location不是对象,需要使用document.location.href.
试试这个:
function goThere() {
var list = document.getElementById('articles');
document.location.href = list.options[list.selectedIndex].value;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
413 次 |
| 最近记录: |