window.open clears parent window

K

KenG

Hi:

I have a datagrid that builds a hyperling which uses javascript to
open a new window. The new window opens and displays fine, however,
the original window that has the grid, is now blank with only
"[object]" displayed in an otherwise empty window. To restore the
datagrid in that window, I have to use the browsers "back" button.

How can I stop the parent window from changing?

Thanks,
Ken
 
R

Ryan Walberg

KenG said:
Hi:

I have a datagrid that builds a hyperling which uses javascript to
open a new window. The new window opens and displays fine, however,
the original window that has the grid, is now blank with only
"[object]" displayed in an otherwise empty window. To restore the
datagrid in that window, I have to use the browsers "back" button.

How can I stop the parent window from changing?

Ensure your <a> tag appears in rendered in one of these two forms:

1. <a href="new_page.aspx" target="someothername">
2. <a href="javascript:window.open("new_page.aspx");">
 
T

Tommy

This behavior can happen when using the <a> tag if the attributes are
not set correctly. Use the javascript function "window.open" instead.

Tommy,
 
K

KenG

Thanks for the reply, Ryan.

Here is the code in the datagrid item databound event. It does render
correctly when viewing it in the status bar of IE

HyperLink c=new HyperLink();
c=(HyperLink)e.Item.Cells[0].Controls[0];
c.NavigateUrl="javascript:window.open('EditOrder.aspx?param="+c.Text+"','_blank','width=530,height=645,toolbar=no,status=yes,scrollbars=yes,resizable=no');";


See anything wrong with this?

Thanks Again !!



Ryan Walberg said:
KenG said:
Hi:

I have a datagrid that builds a hyperling which uses javascript to
open a new window. The new window opens and displays fine, however,
the original window that has the grid, is now blank with only
"[object]" displayed in an otherwise empty window. To restore the
datagrid in that window, I have to use the browsers "back" button.

How can I stop the parent window from changing?

Ensure your <a> tag appears in rendered in one of these two forms:

1. <a href="new_page.aspx" target="someothername">
2. <a href="javascript:window.open("new_page.aspx");">
 
M

Mike Hennessy

Thanks for the reply, Ryan.

Here is the code in the datagrid item databound event. It does render
correctly when viewing it in the status bar of IE

HyperLink c=new HyperLink();
c=(HyperLink)e.Item.Cells[0].Controls[0];
c.NavigateUrl="javascript:window.open('EditOrder.aspx?param="+c.Text+"','_blank','width=530,height=645,toolbar=no,status=yes,scrollbars=yes,resizable=no');";


See anything wrong with this?

Thanks Again !!


Try adding void() like this:

c.NavigateUrl="javascript:void(window.open('EditOrder.aspx?param="+c.Text+"','_blank','width=530,height=645,toolbar=no,status=yes,scrollbars=yes,resizable=no'));";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top