按钮,启动一个url

Button in a case statement, launching a url

本文关键字:一个 url 启动 按钮      更新时间:2023-09-26

下面是我想要开始工作的case语句。我已经在我想要的地方设置了格式,但是此时按钮(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;

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

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

我认为你的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