Javascript – How to automatically allow blocked content in IE

htmlinternet explorerjavascript

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?…

Best Answer

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>