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. | | | | re: Anchor link around input button
"bgold12" <bgold12@gmail.comwrote in message
news:3e0d0bf5-ffaf-435e-810f-278f5104e510@b31g2000prb.googlegroups.com... Quote:
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? | | | | re: Anchor link around input button
On Mon, 3 Nov 2008 19:48:43 -0800 (PST), bgold12 <bgold12@gmail.com>
wrote: Quote:
>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. | | | | re: Anchor link around input button
richard wrote: Quote:
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 | | | | re: Anchor link around input button
Swifty wrote: Quote:
richard wrote: Quote:
>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 | | | | re: Anchor link around input button
Swifty wrote: Quote:
richard wrote: Quote:
>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/ | | | | re: Anchor link around input button
On 2008-11-04, bgold12 wrote: Quote:
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> Quote:
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) | | | | re: Anchor link around input button
Jukka K. Korpela wrote: Quote:
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 | | | | re: Anchor link around input button
In article <scidnQCR6Oe-P43UnZ2dnUVZ8vWdnZ2d@brightview.com>,
Swifty <steve.j.swift@gmail.comwrote: Why do you suppose this and yet quote something that suggests otherwise?
--
dorayme | | | | re: Anchor link around input button
In article <rZOdnfsmtZw33IzUnZ2dnUVZ8uqdnZ2d@brightview.com >,
Swifty <steve.j.swift@gmail.comwrote: Quote:
dorayme wrote: Quote: 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 |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,467 network members.
|