我被这段代码困住了...我试图获取 html 页面,当您单击链接时,调用 bsd 函数,该函数应该弹出一个“foo”警报。我的代码如下。感谢您的帮助!
(function() {
var WshShell = {};
WshShell.log = function() {
console.log(arguments);
}
var bsd = function BSD() {
WshShell.log("foo");
window.alert('foo!');
return false;
}
document.getElementById("bsdTrigger").addEventListener('click', bsd);
})();
<body>
a#bsdTrigger(href='#') foo a#ssddTrigger(href='#') bar
<br />
<a href="#" onclick="javascript:bsd();">bsd</a>
</body>
最佳答案
这似乎工作得很好:http://jsfiddle.net/895vmsok/
<a href="#" id="bsdTrigger" onclick="javascript:bsd();">bsd</a>
也许我误解了您的需求?
关于javascript - 试图让javascript通过html执行wsh,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26964549/