DelphiFAQ Home Search:
General :: Web publishing :: JavaScript
Code snippets to add functionality to your HTML pages, preferably cross-browser.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

How can I prevent the user from typing in a URL


My web pages's JavaScript needs to be notified (event) when the user types a URL in the browser's address field (planning to leave the site?). How can I do this?


It's not possible. The browsers location/address bar is not a JavaScript object, so there are no JavaScript methods for it.

However when someone comes to your site you could check for the window's name. If it is not a specific unusual name (which you hard code now), then you know that it is the first visit and the browser probably does display an address bar.
Just use javascript to open a new window (with the same url) and from there close the opening window (window.opener.

<script language=JavaScript>
 var wn =,6);
 if (wn!="my_secret_name_123") {, 
 else {
   // close the opener
   if (document.opener) {

Generated 12:01:39 on Aug 8, 2020