Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window.Open(...) makes the opener show only a message

Status
Not open for further replies.

juanfd

IS-IT--Management
Jan 21, 2004
45
javascript:window.open('catalogo_fotografia.asp?id=<%=replace(oProducto.sPRODUCTO_URL_imagen_gra,"/","@")%>','','width=350,height=350')"

I have the doe shown an <a href="...">.
The window does open, but as soon as it does, the opener windows shows only a text that sayas [object]. The page that was loaded just vanishes without doing anything but clicking on the link that pops up the new window.

any help gratly appreciated, i've spent hours trying to figure this one out with no luck.



 
It's because the window.open() method returns a reference to the window object that it created. Rewrite your link to look like this:
Code:
<a href="catalogo_fotografia.asp?id=<%=replace(oProducto.sPRODUCTO_URL_imagen_gra,"/","@")%>" target="_blank" onclick="window.open('catalogo_fotografia.asp?id=<%=replace(oProducto.sPRODUCTO_URL_imagen_gra,"/","@")%>','','width=350,height=350');return false;">

The link in the href is if they have JavaScript disabled. If they have JavaScript enabled, the window.open() command will open the window and the "return false" will disable the default behavior of the link (so you don't open up two windows).

If you want your link to always open in the same window, use the target property.

Code:
<a href="catalogo_fotografia.asp?id=<%=replace(oProducto.sPRODUCTO_URL_imagen_gra,"/","@")%>" target="[b]myPopup[/b]" onclick="window.open('catalogo_fotografia.asp?id=<%=replace(oProducto.sPRODUCTO_URL_imagen_gra,"/","@")%>','[b]myPopup[/b]','width=350,height=350');return false;">

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Adam, thank you very much for your response it all works now. :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top