다음과 같은 경우가 있습니다.Javascript set window.name - IE의 문제
웹 사이트 A를 사용하여 웹 사이트 B를 여는 window.open("Website B", "windowName");
사이트 BI에서
다음 코드를 가지고 웹 사이트 CI에서
<script>
window.name='';
window.location.href = 'Website C';
</script>
파이어 폭스 및 크롬 (모든 버전)에있는을 window.name
같음 '이지만 IE (버전 9, 10, 11)에서는 'windowName'과 같습니다.
누군가 설명 할 수 있습니까? 웹 사이트 C에 도착했을 때 항상 window.name = ''
이있는 해결 방법이 필요합니다. 웹 사이트 B에서 windows.open을 사용하여 웹 사이트 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>
문제를 증명하고 다른 사람이 대안을 제공하도록 요청하는 소스 코드가 추가되었습니다. 다시 열어주세요. –
내 경우에는 비록 이름을 설정하고 있었거나 동 기적이 아닌 별도의 Javascript 호출에서 리디렉션을 호출했지만 (MSIE6을 비롯한 다양한 브라우저를 사용하여) 문제를 재현 할 수 없었습니다 - 후에 setTimeout을 통해 document.location을 변경하면 발생합니다 이름 바꾸기? – symcbean
페이지 C의 IE (모든 버전 9-11)에서 여전히 페이지 B와 같은 것을 추가 한 후 window.name = '일부 창 이름'이 표시됩니다. setTimeout (doRedirect, 10000); 페이지 B 코드에만 액세스 할 수 있으므로 페이지 A와 페이지 C는이를 해결하기 위해 변경할 수 없습니다. –