2012-05-03 4 views
0

이상한 문제가 있습니다. 크롬과 같은 일부 브라우저에서는 아래 코드가 새 창을 엽니 다. 그래서 예상대로 작동합니다. 파이어 폭스와 같은 다른 브라우저에서는 경고창을 보여 주므로 요청한 창을 열지 않습니다. 모든 브라우저에서 작동하는 코드에 대한 제안 사항이 있으십니까?javascript : window.location이 모든 브라우저에서 새 창을 열지 않습니다.

if(TestVar == "1810") 
      { 
       alert ("test " + TestVar + "! "); 
       window.location.href="http://astyle.home.xs4all.nl/beautyfarm2003/wellnessbon_321442.html"; 
      } 

if(TestVar == "1920") 
      { 
       alert ("Test " + TestVar + "! "); 
       window.location="http://astyle.home.xs4all.nl/beautyfarm2003/wellnessbon_1925485.html"; 
      } // Vriendinnendag 
+0

열린 새 창, 일명, 당신이 새로운 페이지로 이동하지 않습니다 의미? window.open()을 사용하는 것처럼 들리지만 그렇지 않습니다. – epascarello

답변

0

코드는 Chrome, Internet Explorer 9/10 및 Firefox에서 제대로 작동하는 것으로 보입니다.

새 창을 열려면 http://jsbin.com/uluziz/edit#javascript,html, 당신은 window.location 변경되지 않을 것이다 :

은 다음보십시오. 그 위치가 바뀌는 바로는 현재 창에 있습니다. 새 위치에 새 창을 엽니 대신 window.open() 사용

var myWin = window.open('http://stackoverflow.com','SO','width=640,height=480'); 

setTimeout(function(){ 
    myWin.close(); 
}, 2000); 

데모 : http://jsbin.com/ekoluk/3/edit