Solved

Javascript commands from the browser's address(URL) field

Posted on 2002-07-19
5
767 Views
Last Modified: 2008-01-09
Hi,

is there any way to tell IE(5 or higher) not to respond to commands written in the browser's address bar?

Here is an example, let's say I have this file:
------------
<html>
<head>
<script>
function f1(){var1='Hi there';alert(var1)};
</script>
</head>
<body>
<form name="form1">
<input type="button" value="ClickMe" onClick = f1()>
</form>
</body>
</html>
------------

If you open this file in IE 5 or higher and click the button, and then you type in the browser's address(URL) bar this:

javascript:alert('VAR1 = ' + var1)

IE will show an alert with the value of var1 - this I don't want, is there any way to avoid it?
I don't mean a solution like
alert=null
 - I just don't want IE to respond to commands of any kind written in the address bar - is this possible?
(loading the file into a browser window without an address bar is not a solution either)

Thanks
0
Comment
Question by:peterned
5 Comments
 

Expert Comment

by:perseas
ID: 7166299
try to include this code in your functions or make another function to call it when is needed

if (navigator.appName == 'Microsoft Internet Explorer' )
{

}
0
 

Author Comment

by:peterned
ID: 7166805
perseas,

I can't see how this can make what I want.
My question is:
How to make IE NOT to respond to javascript commands of any kind written in the address bar

What you proposed can't do that
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 200 total points
ID: 7167002
The user owns and controls the browser, and its controls including the address bar.  I assume this is some attempt to restrict the users right to control their own browser, or a vain attempt to protect HTML source code.

Not going to happen.  You can open a new window with no address bar, but you cannot prevent the user from controlling the primary window.

If you detail what you are trying to accomplish by tying to deprive the user of the right to control their browser, maybe we can suggest an alternative; however if yu are trying to keep your source code hidden, you are wasting your time.

Cd&
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8330165
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

points to COBOLdinosaur
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
0
 

Expert Comment

by:modulo
ID: 8395756
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Else condition 9 23
Alert after MVC form submitted 1 22
I have a few questions about using the Google Developer's Console. 4 38
Possible propagation problem 1 22
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question