Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why page gets blank with "[Object]" after javascript:window.open?

I've put a link on one page that opens a new window. the markup it's:

Click <a href="javascript:window.open('../SomePage.aspx', 'mynewwin', 'width=880,height=600,toolbar=0,scrollbars=1,resizable=1');" >HERE</a>.

It happens that when I click the link, the new page shows perfect, but the old one gets blank and only "[Object]" it's writen on it. It should stay as it was.

It's weird!

like image 936
Sergio Avatar asked Mar 27 '26 10:03

Sergio


1 Answers

Because you are not cancelling the click action.

Click <a href="javascript:window.open('../SomePage.aspx', 'mynewwin', 'width=880,height=600,toolbar=0,scrollbars=1,resizable=1');return false;" >HERE</a>

ideally you would not use the href to open the window.

<a target="_blank" href="../SomePage.aspx" onclick="window.open(this.href, 'mynewwin', 'width=880,height=600,toolbar=0,scrollbars=1,resizable=1');return false;" >

even better would be to attach the link event in an unobtrusive manner.

like image 99
epascarello Avatar answered Mar 29 '26 23:03

epascarello