我想要爲我們的IE8筆記本電腦進行地理定位工作的多種選擇,並且調查了Google Chrome Frame(其工作原理)和jquery polyfill(這是我正在嘗試工作的)。該示例取自的網站是webshims,我已驗證所提示的演示頁面在IE8中的工作原理,但我無法爲自己重新創建該示例。這是我的jsp:Webshims,IE8和地理位置
<%@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>
它工作在地理位置的本地支持任何瀏覽器,但填充工具似乎沒有做其工作的IE8。我得到下面的錯誤:
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
我失去的東西,使這個功能正常嗎?
它給出了相同的錯誤,除了添加的代碼是17行而不是13。 – Risu
我沒有看到添加地理位置選項的行:$ .webshims.setOptions('geolocation',{....}); – Maurice
我沒有更新我的帖子以反映添加它的變化,但我確實將它添加到我的本地來源,因此爲什麼我的行號移動。但它並沒有解決問題。 – Risu