简体   繁体   中英

Opening HTML file with Internet Explorer

Good Morning Everyone,

I'm trying to open an HTML file with Internet Explorer (Please, don't mind the version, I've already tried with all of them).

That HTML file uses javascript code to create a Google Map in a div, but every time I try to open it with Internet Explorer, the browser shows the following message:

"Internet Explorer has stopped this page from running scripts or ActiveX controls that could access you computer."

I've already tried to change the security and privacy options but the message is still showing.

This is the javascript code I'm using right now:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script>
    var directionsDisplay;
    var directionsService = new google.maps.DirectionsService();

    function initialize() {
      directionsDisplay = new google.maps.DirectionsRenderer();
      var mapOptions = {
        zoom: 12,
        center: new google.maps.LatLng(40.4889323, -3.6927295),
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      var map = new google.maps.Map(document.getElementById('map-canvas'),
          mapOptions);
      directionsDisplay.setMap(map);
      calcRoute();

    }

    function calcRoute() {
      var start = new google.maps.LatLng(40.4889323, -3.6927295);
      var end = new google.maps.LatLng(40.5485301,-3.648655);
      var request = {
        origin: start,
        destination: end,
        waypoints: [
                    {
                        location: new google.maps.LatLng(40.662707,-3.771187),
                        stopover: true
                    }
                    ],
        travelMode: google.maps.TravelMode.DRIVING
      };
      directionsService.route(request, function(response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
          directionsDisplay.setDirections(response);
        }
      });
    }

    google.maps.event.addDomListener(window, 'load', initialize);

</script>

I will be very grateful if someone can help me or give me some advice about it.

Thank you very much in advance.

This is normal behaviour for Internet Explorer when you open an HTML file from your computer rather than browsing to a web page.

When a file is opened locally, scripts are disabled by default. It may be possible to change this in the configuration, but not advisable. You can just click on the "allow" button and the page will run normally.

Once you publish the file on a web server, IE won't disable the scripts when you browse to it.

If you get tired of the button, you can add a "Mark Of the Web" to the page while you are testing, this will allow scripts to run without the warning:

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

You should naturally remove that before publishing the page to the web.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM