次のシナリオがあります。
Web サイト A は、次を使用して Web サイト B を開いています。window.open("Website B", "windowName");
Web サイト BI には、次のコードがあります。
<script>
window.name='';
window.location.href = 'Website C';
</script>
Web サイト CI では、Firefox と Chrome (すべてのバージョン)window.name
では '' に等しくなりますが、IE (バージョン 9、10、11) では 'windowName' と等しくなります。
誰かが理由を説明できますか?Web サイト C にアクセスするときは常に回避策がwindow.name = ''
必要です。Web サイト B で windows.open を使用して Web サイト C を開くことはできません。window.location を使用する必要があります。
ソースコードが追加されました:
index.html (サイト A)
<!DOCTYPE html>
<html>
<title>Page A</title>
<head>
<script>
function test2(){
window.open("index2.html","Some window name","width=500,height=500");
}
</script>
</head>
<body>
<input type="button" onClick="test2();">
</body>
</html>
index2.html (サイト B)
<!DOCTYPE html>
<html>
<title>Page B</title>
<head>
<script>
document.write("initial window name: [" + window.name + "]<br/><br/>");
window.name=""; //we set it to empty string
document.write("after we set window.name to empty string: [" + window.name + "]"); //all fine in all browsers, shows nothing
document.location= 'index3.html';
</script>
</head>
<body>
</body>
</html>
index3.html (サイト C)
<!DOCTYPE html>
<html>
<title>Page C</title>
<head>
<script>
document.write("initial window name: [" + window.name + "]"); //OK in Firefox (shows nothing). Not OK in IE, shows "Some window name"
</script>
</head>
<body>
</body>
</html>