52

I am using below code for sample menu.

    <html>
<head>
<title>Tree Demo</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.jstree.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
/*       $("#main").jstree({
                "themes" : {
                    "theme" : "default",
                    "dots" : false,
                    "icons" : false
                },
                "plugins" : [ "themes", "json_data", "ui"],
                "json_data" : {
                    "ajax" : {
                        "url" : "jsondata.json",
                        "data" : function (n) {
                            return { id : n.attr ? n.attr("id") : 0 };
                        }
                    }
                }
        });

         $("#main").bind("open_node.jstree", function (e, data) {
                     // data.inst is the instance which triggered this event
                     console.log(data);
                     console.log($.data(data.rslt.obj[0],"folder_name"));
        });
        $("#main").bind("select_node.jstree", function (e, data) {
             // data.inst is the instance which triggered this event
             console.log(data);
             console.log($.data(data.rslt.obj[0],"folder_name"));
        }); */

         $("#main1").jstree({
                "themes" : {
                    "theme" : "default",
                    "dots" : false,
                    "icons" : false
                },
                "plugins" : [ "themes", "html_data"]
        });

    });
</script>
</head>
<body>
    <div id="main1">
        <ul>
            <li><a href="javascript:void(0)">Home Folder</a>
                <ul>
                    <li><a href="javascript:void(0)">Sub Folder1</a></li>
                    <li><a href="javascript:void(0)">Sub Folder2</a></li>
                </ul></li>
            <li><a href="javascript:void(0)">Shared Folders</a>
                <ul>
                    <li><a href="javascript:void(0)">Shared Folder1</a></li>
                    <li><a href="javascript:void(0)">Shared Folder2</a></li>
                </ul></li>
        </ul>
    </div>
    <div id="main">
    </div>
</body>
</html>

when i run the above code in IE browsers it shows top of the page(below the URL bar) like

" To help protect your security , internet explorer has restricted this webpage from running scripts or Activex controls that could access your computer. click for options.. "

when i rightclick and click allowed blocked content, it runs.but i want without this popup message i need to run the code...how can i automatically run this one?...

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ravichandran Jothi
  • 3,028
  • 11
  • 52
  • 82

7 Answers7

81

There is a code solution too. I saw it in a training video. You can add a line to tell IE that the local file is safe. I tested on IE8 and it works. That line is <!-- saved from url=(0014)about:internet -->

For more details, please refer to https://msdn.microsoft.com/en-us/library/ms537628(v=vs.85).aspx

<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html lang="en">
    <title></title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script>
        $(document).ready(function () {
            alert('hi');

        });
    </script>
</head>
<body>
</body>
</html>
Ray Cheng
  • 12,230
  • 14
  • 74
  • 137
  • 3
    Wow! IE never stops surprising me in every aspect possible :) Thank you so much for sharing! – ccpizza Oct 12 '12 at 11:38
  • This method causes many css bugs in IE8 (not sure about other versions). For example, "margin: 0 auto" won't center block elements... – Arsen K. Jan 30 '13 at 08:19
  • 1
    @Webars, the first line is used to get rid of the blocked content popup. I think adding a doctype should fix the css problem. – Ray Cheng Jan 30 '13 at 15:25
  • This does not help the OP — MotW can only ever increase restrictions, never decrease them as the OP desires: « [*By referencing the MOTW, Internet Explorer can force these webpages into a zone that has more restrictions, such as the Internet zone. At the same time, the MOTW cannot be used to elevate webpages to a zone with fewer restrictions.*](http://msdn.microsoft.com/en-us/library/ms537628%28v=VS.85%29.aspx) ». I advise users to attempt this solution before upvoting it. – Barney Jan 27 '14 at 11:49
  • 1
    @Webars the problem comes from inserting content before the doctype declaration, which causes the page to render in quirks mode. Again, this information is available straight from the source: « [*The MOTW appears immediately following the !DOCTYPE declaration.*](http://msdn.microsoft.com/en-us/library/ms537628%28v=VS.85%29.aspx) » – Barney Jan 27 '14 at 11:52
  • 3
    As recommended by Barney, I also suggest users to test out this solution before up voting it since it may not fit your specific needs. – Ray Cheng Jan 27 '14 at 17:47
  • This solution is not working for me. I'm still getting the error. Any idea why ? I'm using IE 9. – Anish V Jan 18 '16 at 09:01
  • it works perfectly for me (IE11), but I'm looking for a better or more accurate way for doing so. take a look at this site: http://block16omaha.com the site is not using your code but the site loads js without any kind of warning msgs. – George Carlin Feb 27 '16 at 20:31
  • wooha. it works (when saved as dos text with the right line endings). so how is that to improve security ??! – commonpike Dec 02 '16 at 21:05
  • downvoted, because the comment should be below the DOCTYPE, the text formatting mattered, and it did not produce consistent results either way – commonpike Dec 02 '16 at 23:26
  • 1
    @commonpike, thank you for pointing that out. It's been revised. – Ray Cheng Dec 02 '16 at 23:53
  • Thanks a million times. – Felipe Costa Gualberto Jun 22 '17 at 12:25
  • @RayCheng After mentioning '' in webpage, links in page having anchor tag '' stopped working. Can you help ? – Alpesh Prajapati Jun 14 '18 at 04:44
37

I believe this will only appear when running the page locally in this particular case, i.e. you should not see this when loading the apge from a web server.

However if you have permission to do so, you could turn off the prompt for Internet Explorer by following Tools (menu) → Internet OptionsSecurity (tab) → Custom Level (button) → and Disable Automatic prompting for ActiveX controls.

This will of course, only affect your browser.

andyb
  • 43,435
  • 12
  • 121
  • 150
16

You have two options:

  1. Use a Mark of the Web. This will enable a single html page to load. It See here for details. To do this, add the following to your web page below the doctype and above the html tag:

    <!-- saved from url=(0014)about:internet -->

  2. Disable this feature. To do so go to Internet Options->Advanced->Security->Allow Active Content... Then close IE. When you restart IE, it will not give you this error.

Steve Rowe
  • 19,411
  • 9
  • 51
  • 82
15

If you are to use the

<!-- saved from url=(0014)about:internet -->

or

<!-- saved from url=(0016)http://localhost -->

make sure the HTML file is saved in windows/dos format with "\r\n" as line breaks after the statement. Otherwise I couldn't make it work.

harrygg
  • 664
  • 1
  • 7
  • 12
9

Steps to configure IE to always allow blocked content:

  1. From Internet Explorer, select the Tools menu, then the Options...
  2. In the Internet Options dialog, select the Advanced tab...
  3. Scroll down until you see the Security options. Enable the checkbox "Allow active content to run in files on My Computer".

enter image description here

  1. Close the dialog, and quit Internet Explorer. The changes will take effect the next time you start IE.

The Blocked Content is a security feature of Windows XP Service Pack 2. If you do not have SP2 installed, then you will never see this message.

From: How To Allow Blocked Content on Internet Explorer

Eddy
  • 3,623
  • 37
  • 44
0

Alternatively, as long as permissions are not given, the good old <noscript> tags works. You can cover the page in css and tell them what's wrong, ... without using javascript ofcourse.

commonpike
  • 10,499
  • 4
  • 65
  • 58
0

That's something I'm not sure that you can change through the HTML of the webpage itself, it's a client-side setting to tell their browser if they want security to be high. Most other browsers will not do this but from what I'm aware of this is not possible to stop unless the user disables the feature.

Does it still do what you want it to do after you click on 'Allow'? If so then it shouldn't be too much of a problem

JakeJ
  • 1,381
  • 3
  • 14
  • 34