window.open clears parent window

  • Thread starter Thread starter KenG
  • Start date Start date
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
 
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");">
 
This behavior can happen when using the <a> tag if the attributes are
not set correctly. Use the javascript function "window.open" instead.

Tommy,
 
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");">
 
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'));";
 
Back
Top