I'm trying to execute Javascript on my web application by executing this on the browser URL/address bar:
javascript:window.alert('test');void(0);
However, nothing happens and the alert box is not showing up? Could the reason be that the app is running in DevMode?
To call JavaScript function from URL or address bar, we can type in a data URL. into the address bar to run the JavaScript code in the script tag. Therefore, we see an alert box that shows 'hi' displayed when we type this in.
To execute JavaScript in a browser you have two options — either put it inside a script element anywhere inside an HTML document, or put it inside an external JavaScript file (with a . js extension) and then reference that file inside the HTML document using an empty script element with a src attribute.
Yes, it can contain executable code (of any kind, including javascript) since URL is a plain string data.
You can write your javascript code inside the block like this
javascript:{alert("ok");}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With