2013-12-13 64 views
2

我點了一個按鈕,並在其中放置了一個javascript函數來打開一個新窗口,如果再次單擊該按鈕,同一個窗口再次刷新並指向它。在firefox和chrome中工作。但不是在IE.Here是我試圖焦點功能在ie8中不工作

<button onclick="popitup('http://www.google.com');">click</button> 

var newwindow = null; 
    function popitup(url) { 
     if ((newwindow == null) || (newwindow.closed)) { 
      newwindow = window.open(url, 'Buy', 'width=950,height=650,scrollbars=yes,resizable=yes'); 
      newwindow.focus(); 
     } else { 
      newwindow.location.href = url; 
      newwindow.focus(); 
     } 
    } 

IE回報newwindow == NULL所有的時間碼...這是問題...任何解決辦法嗎?

+3

這是如何使用C#的? –

+1

默認的按鈕行爲是'submit',所以試着設置'type ='button'' – Grundy

+0

檢查IE是否阻止彈出窗口,也可能重複[在IE9上,Win 7 window.open()返回null而不是引用打開窗口](http://stackoverflow.com/questions/7014242/on-ie9-win-7-window-open-returns-null-instead-of-reference-of-the-opened-wind) – Grundy

回答

0

這是對我的作品

function windowOpen(url) { 
win = window.open(url, 'OpenPage', 'resizable=yes,width=900px,height=620px'); 
win.focus(); 

return false; 

} 

如果沒有,請檢查您的當前窗口的名字是一樣的newwindow如果是plaese使用其他名稱insted的newwindow

+0

@navajyoth ..我試過ie8 – Cronaldo

+0

你檢查你的IE不阻止彈出窗口嗎? –

+0

@NavajyothCS我已經問過:-) – Grundy