I have seen similar posts before, but none of the solutions I have seen online seem to work for me.
I am trying to use a WebBrowser Control to display a locally saved HTML file that uses the Google Maps JavaScript API, but JavaScript remains stubbornly disabled.
To test the problem, I made a simple page using Google Maps based on https://developers.google.com/maps/documentation/javascript/examples/map-simple . I also added a button to directly test if JavaScript was functioning
c:\map-test.html works perfectly in both Firefox and IE.
<!DOCTYPE html>
<html>
<head>
<title>Google Maps JavaScript API v3 Example: Map Simple</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map_canvas {
margin: 0;
padding: 0;
height: 100%;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<input type="button" onclick="alert('JavaScript Functioning');" value="Test JavaScript">
<div id="map_canvas"></div>
</body>
</html>
I then created an MS Access form with a WebBrowser Control named cWebBrowser and added a method to load c:\map-test.html. The Google Maps interface doesn't load and the test button is dead.
Private Sub Form_Current()
Me.cWebBrowser.ControlSource = "=(""file:///C:/map-test.html"")"
End Sub
Next, I tried the online version of map-simple. The JavaScript worked as expected and the Google Map interface loaded
Private Sub Form_Current()
Me.cWebBrowser.ControlSource = "=(""https://google-developers.appspot.com/maps/documentation/javascript/examples/map-simple"")"
End Sub
I have been trying to solve this problem for quite a while without success.
Following this article, http://support.microsoft.com/?kbid=315933 , I enabled the My Computer Zone in IE security settings
In all zones I enabled the following:
Under the Advanced Tab I enabled the following:
Someone suggested adding Mark of the Web to my pages, but that didn't help either.
I have tried clearing the cache.
I have tried changing the filename, in case the cache remained after clearing.
map-test.html works when downloaded in both IE and the WebBrowser Control but only works locally using IE. What else could be causing the problem other than a security setting? Is there a security setting that I am missing? Is there any other test that I could do to diagnose the problem?
I'm at my wits end.
Environment:
Windows 7 64bit
Access 2010
IE 9
P.S.
The problem continues to get weirder
Today, I tried creating an extremely simple JavaScript page to ensure it wasn't the Google Maps code causing the problem.
<!DOCTYPE html>
<html>
<body>
<input type="button" onclick="alert('JavaScript Functioning');" value="Test JavaScript">
</body>
</html>
It worked at first and I was elated. Next, I tried the Google Maps test page and that worked too! So, I tried my full-featured map (working in IE and Firefox) that loads JSON output from my DB application and it all went down in flames, Google Maps code internally caused numerous errors (unfortunately, I didn't document the errors).
Now, I'm back at square one; none of the pages allow scripting, including the 5 liner above ?!?!
First, have a look at Enhanced Protected Mode and Local Files and Understanding Local Machine Zone Lockdown.
I've tested different configurations, using your exact same environment, and they all work (see caveats below).
Created a new form, add a webbrowser control to it then:
Set its ControlSource
to the URL works:
Download the HTML and save it to my desktop, then reference the local file in the ControlSource
works:
Added a button and set the Webbrowser's ControlSource
within its OnClick
event works:
Private Sub Command1_Click()
WebBrowser0.ControlSource = "=""C:\Users\Renaud\Desktop\map-simple.htm"""
End Sub
From the links to the articles about local webpage security I mentioned above, I tried a few things:
If the file in saved in the user's temp folder, it will load properly.
Try it, type %TEMP%
in Explorer and it should take you to C:\Users\username\AppData\Local\Temp
or something equivalent.
Save the html file there and try to load it from Access, for instance using the button on the form above:
Private Sub Command1_Click()
WebBrowser0.ControlSource = "=""C:\Users\Renaud\AppData\Local\Temp\map-simple.htm"""
End Sub
Alternatively, for IE to allow you to open the file, you would need to lower its integrity level so it is forced to run in the Internet zone when IE opens it (and thus make it work properly). You can check the current settings for the file by opening the command prompt (as Administrator):
Now, we can set the file Integrity and check the settings again:
Now you should be able to open the file from Access and IE.
Note though that the ACLs travel with the file when you move them from NTFS system to another NTFS system, but they could be lost if you copy them to a USB flashdrive or another system formatted as FAT for instance, so they may need to be re-applied on the target machine if they are lost.
I tried to add a Mark Of The Web to the file itself, as Remou mentioned, but it doesn't work for me, the file won't load.
Here is what I tried:
<!doctype html>
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<title>Google Maps JavaScript API v3 Example: Map Simple</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
....
One other thing that should work is to try to serve the files from a local http server, like Mongoose
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With