473,320 Members | 1,909 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Anchor link around input button

Hey, I know of two ways to place a link on an HTML page; (1) use the
anchor element, and (2) use javascript to respond to an event (such as
onclick) and set the location.

I recently started using anchors more, and I eventually happened to
try to put an anchor link around an input button, as you can see:

<a href="example.com"><input type="button" value="Example" /></a>

This worked fine in Firefox and Chrome, but it doesn't have any effect
in IE (you can push the button, but nothing happens). Why is this, how
can I fix it, and should I just stick with the javascript method as
shown below:

<input type="button" value="Example" onclick="location.href =
'example.com';" />

Thanks.
Nov 4 '08 #1
10 40544
"bgold12" <bg*****@gmail.comwrote in message
news:3e**********************************@b31g2000 prb.googlegroups.com...
Hey, I know of two ways to place a link on an HTML page; (1) use the
anchor element, and (2) use javascript to respond to an event (such as
onclick) and set the location.

I recently started using anchors more, and I eventually happened to
try to put an anchor link around an input button, as you can see:

<a href="example.com"><input type="button" value="Example" /></a>

This worked fine in Firefox and Chrome, but it doesn't have any effect
in IE (you can push the button, but nothing happens). Why is this, how
can I fix it, and should I just stick with the javascript method as
shown below:

<input type="button" value="Example" onclick="location.href =
'example.com';" />
Why do you want to turn buttons into links? If you just want your links to
look like buttons, then why don't you style them that way?

Nov 4 '08 #2
On Mon, 3 Nov 2008 19:48:43 -0800 (PST), bgold12 <bg*****@gmail.com>
wrote:
>Hey, I know of two ways to place a link on an HTML page; (1) use the
anchor element, and (2) use javascript to respond to an event (such as
onclick) and set the location.

I recently started using anchors more, and I eventually happened to
try to put an anchor link around an input button, as you can see:

<a href="example.com"><input type="button" value="Example" /></a>

This worked fine in Firefox and Chrome, but it doesn't have any effect
in IE (you can push the button, but nothing happens). Why is this, how
can I fix it, and should I just stick with the javascript method as
shown below:

<input type="button" value="Example" onclick="location.href =
'example.com';" />

Thanks.
A standard button is a link if done correctly. Which won't work if JS
is off.
If ya want to do it your way, create an image that looks like a button
and then use anchors. Works with JS off or on.

Nov 4 '08 #3
richard wrote:
A standard button is a link if done correctly. Which won't work if JS
is off.
However, unless I've missed some trick, the resulting URL will have at
least a trailing "?". This may be browser-specific, but I don't think so.

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Nov 4 '08 #4
Swifty wrote:
richard wrote:
>A standard button is a link if done correctly. Which won't work if JS
is off.

However, unless I've missed some trick, the resulting URL will have at
least a trailing "?". This may be browser-specific, but I don't think so.
The lesson here is use a *link* for a *link*, not a form control...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Nov 4 '08 #5
Swifty wrote:
richard wrote:
>A standard button is a link if done correctly. Which won't work if JS
is off.

However, unless I've missed some trick, the resulting URL will have at
least a trailing "?". This may be browser-specific, but I don't think
so.
It's not browser-specific. And "richard" is of course wrong as usual, with
just enough factoids accidentally included to confuse many people.

A button as such is not even a pseudolink. When wrapped inside a form, it
somewhat corresponds to a link. Using the button resembles then following a
link to the URL in the action attribute of the form, _except_ that you lose
most of the functionality of links.

The trailing "?" is not a problem since it is ignored by servers unless you
do something extravagant to make them treat it in some special way.
Actually, "?" followed by a string is ignored if the server has not been
programmed or configured handle it.

If you use method="POST" in the <formtag, the "?" won't be appended, but
who cares?

--
Yucca, http://www.cs.tut.fi/~jkorpela/

Nov 4 '08 #6
On 2008-11-04, bgold12 wrote:
Hey, I know of two ways to place a link on an HTML page; (1) use the
anchor element, and (2) use javascript to respond to an event (such as
onclick) and set the location.

I recently started using anchors more, and I eventually happened to
try to put an anchor link around an input button, as you can see:

<a href="example.com"><input type="button" value="Example" /></a>
Why do you need a button? You can style the link to look like one:

<a href="example.com"
style="background: #ddd; color: black; border: 2px outset #555">
Example</a>
This worked fine in Firefox and Chrome, but it doesn't have any effect
in IE (you can push the button, but nothing happens). Why is this, how
can I fix it, and should I just stick with the javascript method as
shown below:

<input type="button" value="Example" onclick="location.href =
'example.com';" />

--
Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
================================================== =================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Nov 4 '08 #7
Jukka K. Korpela wrote:
The trailing "?" is not a problem since it is ignored by servers unless
you do something extravagant to make them treat it in some special way.
Actually, "?" followed by a string is ignored if the server has not been
programmed or configured handle it.

If you use method="POST" in the <formtag, the "?" won't be appended,
but who cares?
Just in case anyone is curious, a CGI script is passed the URI in the
environment variable REQUEST_URI.

I have some webpages that use that value to build other links to the
same page, but with optional parameters.

So starting with http://server.com/page that submits a form to the same
URL with ACTION=GET, I end up with the URI being http://server.com/page?
If I now use this to build links with parameters, by appending "?parms"
to the URI value then I end up duplicating the "?". After a few passes,
I can end up with several "?"s in a row. Of course, it is easy to work
around this, but finding a way to stop the "?" getting into the browsers
Location: field in the first place would be the best in many ways.
Especially as a way of stopping the email from people with nothing
better to do than ask me why my URL's sometimes have an "?" on the end.
And yes, I have had such mail. With sufficient users, you eventually get
asked every conceivable question. I suppose eventually I'll receive the
complete works of Shakespeare, as a mistype.
See http://www.swiftys.org.uk/wiz?487

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Nov 4 '08 #8
In article <sc******************************@brightview.com >,
Swifty <st***********@gmail.comwrote:
I suppose eventually I'll receive the
complete works of Shakespeare, as a mistype.
See http://www.swiftys.org.uk/wiz?487
Why do you suppose this and yet quote something that suggests otherwise?

--
dorayme
Nov 4 '08 #9
dorayme wrote:
>I suppose eventually I'll receive the
complete works of Shakespeare, as a mistype.
See http://www.swiftys.org.uk/wiz?487

Why do you suppose this and yet quote something that suggests otherwise?
I can see both sides of the argument. That's the advantage of being
two-faced.

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Nov 5 '08 #10
In article <rZ******************************@brightview.com >,
Swifty <st***********@gmail.comwrote:
dorayme wrote:
I suppose eventually I'll receive the
complete works of Shakespeare, as a mistype.
See http://www.swiftys.org.uk/wiz?487
Why do you suppose this and yet quote something that suggests otherwise?

I can see both sides of the argument. That's the advantage of being
two-faced.
OK, but my complaint is you being three-faced. You see, if you had
suggested both things at the same level of suggestion, that would be two
faced. But that is not what you did. You supposed one thing openly, you
suggested another thing and, because of the relations between the
suppositon and the suggestion, a third thing was borne at another level.
I don't think you realise how evil you are. <g>

--
dorayme
Nov 5 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: elsenraat_76 | last post by:
Hello! I was wondering if someone could help me out with a problem I'm having? I'm trying to input a javascript value into an anchor tag (from a function), but don't have an event to call the...
9
by: kojim | last post by:
Test page: http://www.key-horse.com/linkt.html I have a td that's styled to look something like a button, and on that button is anchor text. So far, I can't make the entire "surface" of the...
10
by: elibol | last post by:
Hi, Is there an event that fires when the back or forward button on a browser is pressed? I need an event to fire when someone clicks the back or forward button after an anchor has been set. ...
8
by: knoxautoguy | last post by:
This problem has consumed a lot of my time, and I'm aftraid someone will tell me that my whole approach to this objective is wrong; however, I would like to know if there is a way to do this. I...
2
by: rudranee | last post by:
Hi, Can i hide an anchor tag in the mailto form?so that only the receiver is able to see it. The refernce code is given here: <FORM METHOD=POST ACTION="mailto:abc@xyz.com"...
20
by: Prisoner at War | last post by:
Hi, People, Is it possible to have an "empty" or "dummy" <a href***without*** the browser jumping back up the page?? I have a hyperlink that doesn't point to another document, but is used to...
3
by: shapper | last post by:
Hello, In a page I have: 1. An input (type="submit") button that submits a form. 2. An anchor that cancels the form submission and redirects the user to a page. I am trying to make both look...
6
by: shapper | last post by:
Hello, On a bottom of a form I have 2 buttons: Submit and Cancel. Submit is an input and submits the form. Cancel should just redirect the user to a new page without submitting the form. I...
8
by: azjudd | last post by:
Thank you in advance for your help on this one. I'm using named anchor tags on a FAQ page with questions listed at the top and answers below; a standard jump-to feature. However, anytime an anchor...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.