Click to See Complete Forum and Search --> : opening a new window


robsw
10-14-2003, 05:24 PM
I have an asp page and was wondering if I could open a new window using javascript based on the following code:

% if rs2("Calculation") <> "" then %><a href="/news/<% = rs2("Calculation")%>">Calculation</a></p>
<% end if %>

I have tried the following but it still opens in the same window.

<% if rs2("Calculation") <> "" then %><p><a href="/news/<% = rs2("Calculation")%"><onclick="window.open'', 'myWindow', 'height=400,width=200');">Calculation</a></p>
<% end if %>

Any suggestions?

Khalid Ali
10-14-2003, 07:02 PM
it seems like the code is incorrect,it should be like this(un ested)

<% if rs2("Calculation") <> "" then %><p><a href='/news/<%=rs2("Calculation")%>' onclick="window.open('', 'myWindow', 'height=400,width=200');">Calculation</a></p>

robsw
10-15-2003, 09:15 AM
Hi Khalid,

Thanks for your help. A window pops up but it is blank and the content that should be in the pop up window changes in the parent window. How would I make it so the content in the parent window does not change and the pop up window has the content? I know the url should be the first parameter but I'm unsure as to how to refer to the page I want displayed since the page is being retrieved from a database.

Rob

Khalid Ali
10-15-2003, 10:23 AM
you will need to make sure that you have nothing in href
<a href="#"

and add the following at the end of the onclick event

return false;

ad the url of the page that you want to open in the popup as the first parameter

<% if rs2("Calculation") <> "" then %><p><a href='/news/<%=rs2("Calculation")%>' onclick="window.open('pageToOpen.html', 'myWindow', 'height=400,width=200');return false;">Calculation</a></p>

robsw
10-15-2003, 10:45 AM
Thanks a lot for your help Khalid!!

I was able to get it with this..

<% if rs2("Calculation") <> "" then %><p>&nbsp;&nbsp;<a href= '#'onclick="window.open('/news/<%=rs2("Calculation")%>','','height=600,width=800,scrollbars=yes');return false;">Calculation</a></p><% end if %>