I accidentally used Shift Left Click to click on a hyperlink whose link target (href) was a script. As a result, a dialog box for whether to debug the script appeared. Clicking yes can actually open the debugging script, but where does this script come from?
Looking back at the newly opened IE, the address bar said: javascript:open(url). It turns out that the address bar of IE can use the "JavaScript:" statement to execute scripts. Now I try JavaScript:alert('ok'), and it works fine!
It’s a fun feature, let’s write some more complex scripts: javascript: var s=''; for( var i=0; i http://www.google.com, enter in the address bar: javascript: document.getElementsByTagName('Input')[1 ].disabled = true; alert('');, what will you see? Can't you enter the query keyword?
In fact, the scope of the script running in the address bar is the script scope of the current page. Using this feature, we can not only simply execute script statements, but also assist us in debugging scripts. For example, I want to view the values of some variables, and we do not need to enter complex debugging mode. The picture below is my debugging popup menu<.> is an example. This method can avoid writing status=... everywhere when debugging code.
Here we can not only write JavaScript: in the address bar, but also write vbscirpt: alert("ok!"), ecmascript: and jscirpt. However, ecmascript will be automatically converted to javascirpt, and jscript will be converted to vbscript. Although this feature is simple, I hope everyone can play it. And play more tricks.