在case语句中按下,启动一个url

时间:2013-03-21 21:37:37

标签: javascript html websense

以下是我试图开始工作的案例陈述。我将格式设置放在我想要的位置,但此时按钮(onclick)没有任何操作。

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;

2 个答案:

答案 0 :(得分:1)

你不应该通过html绑定元素内的事件,这使得调试javascript非常困难。您可以使用document.write创建元素,然后在执行此操作后,可以使用DOM引用元素并以此方式添加事件。 这是一个例子:

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

http://jsfiddle.net/5QxuD/

答案 1 :(得分:0)

我认为您的onClick调用可能有误。

尝试:

window.open("http://aceinsight.websense.com/?url= (rest of your url)")

而不是:

window.open=("http://aceinsight.websense.com/?url= (rest of your url)")

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