Sometimes, we want to call JavaScript function from URL or address bar.
In this article, we’ll look at how to call JavaScript function from URL or address bar.
How to call JavaScript function from URL or address bar?
To call JavaScript function from URL or address bar, we can type in a data URL.
For instance, we type in
data:text/html,<script>alert('hi');</script>
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.
Conclusion
To call JavaScript function from URL or address bar, we can type in a data URL.