A Href and onClick Button

Hi I have here a link that executes a function (pops open window)  nicely but when I tried to convert it to button onClick it doesn't do what it is supposed to do. Where is my error?

The link:
<a title="comment on this post" class="h5_b" href="somepage.html" onclick="popWindow(this.href);return false;">Search!</a>

The button:
<input name="runSearch" type="button" class="button_small" value="Search!" onClick="javascript:popWindow('somepage.html');return false;">

(the 'return false' needs to stay there)
LVL 1
champ_010Asked:
Who is Participating?
 
jaysolomonCommented:
if you are using a btn and JS is turned off then all the button will do is you will be able to click it but will not go or do anything

try this
<input name="runSearch" type="button" class="button_small" value="Search!" onClick="window.open('somepage.html');">
0
 
jaysolomonCommented:
<input name="runSearch" type="button" class="button_small" value="Search!" onClick="popWindow('somepage.html');return false;">
0
 
ZvonkoSystems architectCommented:
No, it needs not to be there.

But anyway, it should work.

Check this:
<input name="runSearch" type="button" class="button_small" value="Search!" onClick="popWindow('somepage.html')">



0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
ChillerCommented:
I guess this.href doesnt work in every browser
0
 
jaysolomonCommented:
yes it works, just buttons do not have href's
0
 
champ_010Author Commented:

Hi, neither of your samples work for my function -- it doesn't work for the button but it does work if I changed it to a link.  I need the return false there because if someone didn't have javascript turned on it would still display as a page in place of parent page instead of a pop up.
0
 
champ_010Author Commented:

jaysolomon's comment didn't solve the button problem but it certainly answered my question--I will probably stick with using an a href for this.

Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.