View Full Version : avoiding IE security warning when using javascript

01-26-2006, 11:35 PM
I am trying to do a simple version of something that I saw on Foxton's website:


(from the map, if you click on Queens, it causes a list of neighborhoods to appear)

I tested that, and it works in IE, Mozz and Firefox.

So, I tried to make a simplified version that would perform the same task, but when I test it in IE, I recieve a warning in the toolbar that says, "To help protect your security, Internet Explorer has restricted this file from showing active content that could access your computer. Click here for options..."

my simple version only uses javascript (as does Foxton's site), but the Foxton site does not generate that same warning.

What gives ???

Here is my dopey code, just so you can see what IE is barking about.
I have already provided a link to Foxton's site (above). No barks from IE on that one.

I would just like to accomplish this very simple task without causing IE any undue stress.
Any help would be appreciated.


<script language ="javascript">

function d1()
document.all.div1.style.display = 'block';
document.all.div2.style.display = 'none';
document.all.div3.style.display = 'none';

function d2()
document.all.div1.style.display = 'none';
document.all.div2.style.display = 'block';
document.all.div3.style.display = 'none';

function d3()
document.all.div1.style.display = 'none';
document.all.div2.style.display = 'none';
document.all.div3.style.display = 'block';



<div style="position:absolute; left:200px; top:50px;">
<div id="div1" STYLE="display: none">DIV 1 text</div>
<div id="div2" STYLE="display: none">DIV 2 text</div>
<div id="div3" STYLE="display: none">DIV 3 text</div>

<div style="position:absolute; left:300px; top:300px;">
<input type="radio" name="r1" onClick="d1();">
<input type="radio" name="r1" onClick="d2();">
<input type="radio" name="r1" onClick="d3();">


01-27-2006, 12:20 AM
IE complains when you open an HTML file that contains JavaScript on your local machine.

It won't complain if the same file is actually on a web server.

01-27-2006, 12:32 AM
it is because you havent activated "active scripting" in IE's zone-settings for local pages while it is allowed for internet-pages

01-27-2006, 10:57 AM
The security prompt appears in IE6 on XP SP2 by default as a security measure when running local html files. You can change the settings of course but for your protection it's not recommended to do so, that's why MS sets it like that by default. And as Mongus said, it will not appear when the page is run from a Web server whether on Intranet or Internet.

There's also a feature in IE called Mark of the Web (MOTW) (http://msdn.microsoft.com/workshop/author/dhtml/overview/motw.asp).

<!-- saved from url=(0022)http://www.google.com/ -->

It forces Web page to run under the security zone of the location specified in MOTW. If the location is an internet URL, the local page is run in Internet zone where that security prompt is disabled by default. So if your local html file contains the above MOTW at the top of the page after DOCTYPE declaration, the prompt will not appear and the script will run as if it's run from a web server.