473,372 Members | 1,047 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,372 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 40553
"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...
1
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.