简体   繁体   中英

focus function not working in ie8

I have a button click and in it i put a javascript function to open a new window and if i again click the button the same window refresh again and point to it.Working both in firefox and chrome.but not in IE.Here is the code i tried

<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 return newwindow==null all the time...that is the issue...any solution?

It's Works for me

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

return false;

}

If not please check for your current window name is same as newwindow if yes plaese use another name insted of newwindow

Take a look at that:

http://hardlikesoftware.com/projects/IE8FocusTest.html

Hope it helps..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM