我的问题是在IM的Prestashop工作(1.6.1.9)CMS网页,即时通讯不许放任何脚本到CMS的网页源代码。(我不是使用iframe中对于这一点,它不是一个解决方案)..的Javascript链接<select> ID
所以我有一个下拉菜单,其中每个链接上的下拉链接到某个页面。我想用一个java脚本功能来做到这一点。
但因为我不能这样调用示例中的页面上的JavaScript,
<select id="selectdrops" name="newurl" onchange="menu_goto(this.form) ">
<option value="/index.html">Home</option>
<option value="/feedback.html">Feedback</option>
<option value="/links.html">Related Links</option>
</select>
我愿我的javascript重点下拉“ID”如果多数民众赞成可能吗?
删除:menu_goto(this.form)我想仍然可以完成有针对性的链接,可能只关注选择“ID”。
我的.js文件看起来是这样的:
$(document).ready(function() {
$(document).on('change', '#dropSelectAbout', function (e) {
e.preventDefault();
menu_goto();
});
$(document).ready(function() {
$("a").click(function(event) {
alert(event.target.id);
});
});
});
function menu_goto(menuform)
{
var baseurl = window.document.location.protocol + '//' + window.document.location.host;
selecteditem = menuform.newurl.selectedIndex ;
newurl = menuform.newurl.options[ selecteditem ].value ;
if (newurl.length != 0) {
location.href = baseurl + newurl ;
}
}
你是真正的英雄,工作,感谢! – Ylama