2

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?

Cronaldo
  • 99
  • 1
  • 12
  • 3
    How does this use C#, exactly? – Chris Hayes Dec 13 '13 at 08:11
  • 1
    default button behavior is `submit`, so try set `type='button'` – Grundy Dec 13 '13 at 08:28
  • Check that IE does not block popup windows, also possibly duplicate [On IE9, Win 7 window.open() returns null instead of reference of the opened window](http://stackoverflow.com/questions/7014242/on-ie9-win-7-window-open-returns-null-instead-of-reference-of-the-opened-wind) – Grundy Dec 13 '13 at 10:16
  • @Grundy ..IE return newwindow==null all the time...that is the issue...any solution? – Cronaldo Dec 13 '13 at 10:21
  • @AnilkumarM do you check that IE does not block popups? are you going by link? – Grundy Dec 13 '13 at 10:24

2 Answers2

0

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

Navajyoth CS
  • 968
  • 2
  • 7
  • 15
0

Take a look at that:

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

Hope it helps..

kudra
  • 134
  • 1
  • 15
  • IE return newwindow==null all the time...thts the issue...any solution? – Cronaldo Dec 13 '13 at 09:49
  • sorry wrong link. have u seen this: http://stackoverflow.com/questions/1326993/jquery-focus-sometimes-not-working-in-ie8 – kudra Dec 13 '13 at 11:09