从地址栏执行JavaScript会导致浏览器退出页面? [英] Executing JavaScript from the address bar causes the browser to exit the page?

查看:89
本文介绍了从地址栏执行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.

这篇关于从地址栏执行JavaScript会导致浏览器退出页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆