Click to See Complete Forum and Search --> : Quick Question - Window.open()


RJ2003
05-07-2003, 04:54 AM
hi guys,

I have a href in a jsp which opens a new browser window using

<a href="javascript:window.open('<%=rs.getString("url")%>','<%=rs.getString("name")%>')"><%= rs.getString("name") %></a>

On clicking the link, it does open a new browser window as expected BUT the parent window browser becomes empty with only one thing written i.e. [object].

Where am i going wrong ? :(

KeshavaR
05-07-2003, 05:13 AM
Try using -

onClick Event instead of <a href></a>, which would eventually trigger a function having your window.open code

function test()
{
window.open('<%=rs.getString("url")%>','<%=rs.getString("name")%>')"><%= rs.getString("name") %>
}

and <td onclick="test()">Link Name Here</td>

Charles
05-07-2003, 05:18 AM
That would be bad. It would give you a link that didn't do anything for one in ten people and cause all kinds of trouble for people using non-visual browsers. Use instead:

<a href="<%=rs.getString("url")%>" onclick="window.open(this.href, '<%=rs.getString("name")%>'); return false"><%=rs.getString("name")%></a>

RJ2003
05-07-2003, 05:47 AM
Thanks Charles & KeshavaR....i used Charles solution and it worked.

Great !