【发布时间】:2011-08-09 01:28:54
【问题描述】:
我一直在一个 wordpress 网站上实习,我想在页面中嵌入 javascript 代码以创建一个下拉菜单,将浏览器导航到所选页面。
我想知道,您需要做一些特别的事情来让 js 在 wp 页面中工作吗? 我尝试使用发布选项的 html 端在页面中嵌入以下代码:
<script language="javascript" type="text/javascript">
<!--
function menu_goto( menuform )
{
// see http://www.thesitewizard.com/archive/navigation.shtml
// for an explanation of this script and how to use it on your
// own site
var baseurl = "173.236.164.86/where-to-buy/" ;
selecteditem = menuform.newurl.selectedIndex ;
newurl = menuform.newurl.options[ selecteditem ].value ;
if (newurl.length != 0) {
top.location.href = baseurl + newurl ;
}
}
//-->
</script>
<form action="dummyvalue">
<select name="newurl" onchange="menu_goto(this.form)">
<option value="" selected="selected">----- Select A Product -----</option>
<option value="vene-prototype-version/">VENE Prototype Version</option>
<option value="configuration-vene-version/">VENE Configuration Version</option>
<option value="customized-vene-version/"> VENE Customized Version</option>
</select>
</form>
出现下拉菜单,但无法在更改时重定向浏览器。
我试过用 标签包围页面中的代码,但也没有效果。
http://173.236.164.86/where-to-buy/
感谢您的帮助!
【问题讨论】:
标签: javascript wordpress navigation drop-down-menu