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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pop up window code?

Status
Not open for further replies.

wolf73

Programmer
Joined
Feb 12, 2006
Messages
93
Location
CA
Is there anything wrong with the following code, when I click nothing happens ........


<a href='javascript:;' onclick='MM_openBrWindow('benefits.html','benifits','scrollbars=yes,width=560,height=400')'><img src='images/b_2.gif' border='0' height='28' width='64'/></a>


But following code works

<a href=javascript:MM_openBrWindow('procedures.html','program','scrollbars=yes,width=560,height=400')><img src='images/b_1.gif' border='0' height='28' width='73'/></a>
 
Use quotes instead:
Code:
<a href=[!]"[/!]javascript://;[!]"[/!] onclick=[!]"[/!]MM_openBrWindow('benefits.html','benifits','scrollbars=yes,width=560,height=400')[!]"[/!]><img src=[!]"[/!]images/b_2.gif[!]"[/!] border=[!]"[/!]0[!]"[/!] height=[!]"[/!]28[!]"[/!] width=[!]"[/!]64[!]"[/!]/></a>
Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
thanks i tried "" but it did not work, so I will use the 2nd code ..... thanks
 
wolf73, the idea is not to replace ALL single quotes with double, but only the specific ones that BabyJeffy highlighted in red.

You have to have a matching start and end quote for each section. The problem is that you used all single quotes so the first quote before javascript:; is terminated by the one directly at the end of javascript:; which is telling the browser that everything between those two quotes belongs to href=. Then you have your onclick event and all the info inside that onclick has to be encased in quotes as well so you start it with onclick='MM_openBrWindow(' and there is your problem. The quote you intended to put at the beginning of benefits.html acts as the terminating quote to the one at the beginning of the onclick event so your onclick event functionally reads onclick='MM_openBrWindow(' and that is the end of the onclick.
You can mix single and double quotes to avoid these problems like this:
onclick="MM_openBrWindow('benefits.html','benifits','scrollbars=yes,width=560,height=400')"
Or in reverse:
click='MM_openBrWindow("benefits.html","benifits","scrollbars=yes,width=560,height=400")'

This way the onclick event contains everything within one type of quotes and the values in the function call are contained in a different type of quote.



It's hard to think outside the box when I'm trapped in a cubicle.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top