从地址栏执行JavaScript会导致浏览器退出页面?

问题描述:

我正在测试一个网页,我想从地址栏执行一些JavaScript代码来更改一些内容(例如更改div的内容)
我加载了网页并在地址栏中输入了以下:

I'm testing a webpage, and I want to execute some JavaScript code from the address bar to change some content (e.g. changing the content of a div) I loaded the webpage and typed in the address bar the following:

javascript:document.getElementById("message").innerHTML="anotherthing"

并且,在执行上面的代码之后,浏览器会更改div的内容,但是它会立即退出页面。

And, after executing the above code, the browser changes the content of the div, but inmediatly it exits the page.

我该如何避免这种行为?

How can I avoid that behavior?

谢谢。

添加一个void(0);到最后,它将修复它。

Add a void(0); to the end and it will fix it.