Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute Javascript method from browser address bar - GWT

Tags:

javascript

gwt

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?

like image 355
quarks Avatar asked Sep 13 '13 09:09

quarks


People also ask

How do you call a JavaScript URL?

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.

How do you run a .JS file in a browser?

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.

Can you embed JavaScript in URL?

Yes, it can contain executable code (of any kind, including javascript) since URL is a plain string data.


1 Answers

You can write your javascript code inside the block like this

javascript:{alert("ok");}
like image 163
LJRKUMAR Avatar answered Nov 08 '22 12:11

LJRKUMAR