首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >按钮,启动一个url。

按钮,启动一个url。
EN

Stack Overflow用户
提问于 2013-03-22 05:37:37
回答 2查看 145关注 0票数 0

下面是我正在尝试开始工作的case语句。我已经将格式放在我想要的位置,但是此时按钮(onclick)没有任何操作。

代码语言:javascript
复制
case 'This Websense category is filtered: <b>Uncategorized</b>.':
document.write('<p><b style="margin-left: 8px;">Help:</b><INPUT TYPE="button" STYLE="margin-left: 64px;" VALUE="Submit UNCATEGORIZED website to Websense" onClick="window.open=(http://aceinsight.websense.com/?url=' + 
'$*WS_URL*$,' + ' "_blank")' + '"></p>\
<hr />\
<p style="margin-left: 108px; color: #FF0000;">Clicking on the above button will open another webpage for Websense to categorize the above site. You will NOT receive a confirmation e-mail or any communication from Websense indicating your request is processing. Please note the response time for your request will vary. Allow three to four (3-4) hours for updates to take effect once approved.</p>');
break;
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-03-22 05:48:04

你不应该通过html在元素中绑定事件,这会使javascript的调试变得非常困难。可以使用document.write创建元素,然后可以使用DOM引用元素并以这种方式添加事件。下面是一个例子:

代码语言:javascript
复制
document.write('<button id="foo">Hai!</button>');
document.getElementById('foo').onclick = function () {
    window.open('http://aceinsight.websense.com/',"_blank");
};

http://jsfiddle.net/5QxuD/

票数 1
EN

Stack Overflow用户

发布于 2013-03-22 05:44:05

我想你的onClick调用可能是错误的。

尝试:

代码语言:javascript
复制
window.open("http://aceinsight.websense.com/?url= (rest of your url)")

而不是:

代码语言:javascript
复制
window.open=("http://aceinsight.websense.com/?url= (rest of your url)")

https://developer.mozilla.org/en-US/docs/DOM/window.open

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15558682

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档