Link to home
Start Free TrialLog in
Avatar of champ_010
champ_010

asked on

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)
Avatar of jaysolomon
jaysolomon

<input name="runSearch" type="button" class="button_small" value="Search!" onClick="popWindow('somepage.html');return false;">
Avatar of Zvonko
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')">



I guess this.href doesnt work in every browser
yes it works, just buttons do not have href's
Avatar of champ_010

ASKER


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.
ASKER CERTIFIED SOLUTION
Avatar of jaysolomon
jaysolomon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

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.