[英]Invalid procedure call or argument IE issue when iterating through document.styleSheets using $.each()
[英]IE 8's invalid procedure call or argument
我想在子窗口(由window.open創建)中訪問開瓶器類,
w3c瀏覽器工作正常,但在IE 8中失敗。
我還測試了iframe,它在所有瀏覽器中都能正常工作。 該示例的目的是減少Google地圖的負載
父窗口
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://maps.google.com/maps/api/js?sensor=false&language=cn"></script>
<script>
function openIEWin(){
var TRACK = window.open('child.html?t='+new Date().getTime(),'');
TRACK.focus()
}
</script>
</head>
<body style="background-color:#cfc;" class="abc">
<button onclick="openIEWin()">New Window</button>
<!--iframe page can successfully access and invoke the parent window's class-->
<iframe src="b.html"></iframe>
子窗口:
<!DOCTYPE html>
<html>
<head>
</head>
<body onload="init()">
<div id='map' style="width:600px;height:480px;"></div>
<script>
function init(){
var google= window.opener.google;
//cause an error
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center:latlng
};
//cause an error
var map = new google.maps.Map(document.getElementById('map'),myOptions);
}
</script>
錯誤消息是如此典型:
無效的過程調用或參數
然后我嘗試了IE的window.showModelessDialog,但是遇到了同樣的錯誤。
那么如何解決這個問題呢?
看來我們不能使用new創建實例?
我猜想這與IE不真正支持在Windows之間傳遞對象有關。 如果谷歌地圖代碼在任何時候嘗試在配置對象上調用JSON.stringify,那么我認為將拋出此錯誤,因為JSON.stringify無法將對象識別為有效對象。
嘗試將這段代碼移至打開頁面,然后從子頁面調用此方法,並傳遞要顯示在( document.getElementById('map')
)中的元素作為參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.