| Programming C# C++ (7) Delphi (618) Java (8) JavaScript (30) Document (8) Events (8) ExtJS (8) Strings (3) perl (9) php (4) VBScript (1) Visual Basic (1) |
How can I prevent the user from typing in a URL
Question: 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?Answer: 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.
Comments:
|