Solved

A Href and onClick Button

Posted on 2004-04-26
7
5,717 Views
Last Modified: 2009-12-16
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)
0
Comment
Question by:champ_010
7 Comments
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10917960
<input name="runSearch" type="button" class="button_small" value="Search!" onClick="popWindow('somepage.html');return false;">
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10917968
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
 

Expert Comment

by:Chiller
ID: 10918601
I guess this.href doesnt work in every browser
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:jaysolomon
ID: 10918636
yes it works, just buttons do not have href's
0
 
LVL 1

Author Comment

by:champ_010
ID: 10919164

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
 
LVL 16

Accepted Solution

by:
jaysolomon earned 50 total points
ID: 10919197
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
 
LVL 1

Author Comment

by:champ_010
ID: 10920100

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Only allow one check box 17 38
Javascript Regex 7 20
Getting selected value using Jquery 3 19
JS to redirect to prev page 8 16
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question