0

以下是我试图开始工作的案例陈述。我在我想要的地方设置了格式,但是此时按钮(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;
4

2 回答 2

1

You shouldn't bind events inside the elements via html, it makes debugging javascript very difficult. You can create the element with document.write, and then after you do that you can reference the elements using the DOM and add an event that way. Here's an example:

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

http://jsfiddle.net/5QxuD/

于 2013-03-21T21:48:04.240 回答
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

于 2013-03-21T21:44:05.227 回答