I wanted multiple options for making geolocation work for our IE8 laptops and have investigated both the Google Chrome Frame (which works) and the jquery polyfill (which is what I am trying to get working). The website the example was taken from is webshims and I have verified that the mentioned demo page works in IE8, but I can't recreate the example for myself. This is my jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
  <head>
    <meta charset=utf-8>
    <title>Geolocation</title>
    <script src="<c:url value="/js/jquery-1.6.4.min.js"/>" type="text/javascript"></script>
    <script src="<c:url value="/js/modernizr-latest.js"/>" type="text/javascript"></script>
    <script src="<c:url value="/js/polyfiller.js"/>" type="text/javascript"></script>
    <script type="text/javascript">
      //http://afarkas.github.com/webshim/demos/demos/geolocation.html
      $.webshims.polyfill();
      navigator.geolocation.getCurrentPosition(function(pos){ $("#status").html("found you! latitude: "+ pos.coords.latitude +"/longitude: " + pos.coords.longitude); });
    </script>
  </head>
  <body>
    <p>Finding your location: <span id="status">checking...</span></p>
  </body>
</html>

It works in any browser where geolocation is natively supported, but the polyfill doesn't seem to be doing its job for IE8. I get the below error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; chromeframe/15.0.874.121; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) Timestamp: Wed, 7 Dec 2011 17:48:06 UTC

Message: 'navigator.geolocation' is null or not an object Line: 13 Char: 7 Code: 0 URI: ../GeoLocation/jquery.action

Am I missing something to make this function properly?

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top