/    Sign up×
Community /Pin to ProfileBookmark

<a href problems with putting a button as a link

i know you can do a simple javascript onClick command and do a link but wouldnt it be nicer if we can make a button link for every browser?

ive seen it been done with images so can it be done with buttons?

[code]
<!–this is what i have so far–>
<a href=http://www.yahoo.com><input type=”button” value=”Yahoo!”></a>
[/code]

to post a comment
HTML

12 Comments(s)

Copy linkTweet thisAlerts:
@David_HarrisonJan 03.2005 — Is all of this code worth it just for a tacky button link?&lt;script type="text/javascript"&gt;

document.write('&lt;form action="#" onsubmit="return false;"&gt;');
document.write(' &lt;p&gt;
document.write(' &lt;input type="button" value="Click here to go to Yahoo!" onclick="location.href=\'http://www.yahoo.com\';"&gt;');
document.write(' &lt;p&gt;');
document.write('&lt;/form&gt;');

&lt;/script&gt;

&lt;noscript&gt;
&lt;p&gt;
&lt;a href="http://www.yahoo.com"&gt;Click here to go to Yahoo!&lt;/a&gt;
&lt;/p&gt;
&lt;/noscript&gt;
Copy linkTweet thisAlerts:
@CharlesJan 03.2005 — [font=monospace]<form action="http://www.w3.org/">

<div><button type="submit">W3C</button></div>

</form>[/font]
Copy linkTweet thisAlerts:
@age13kidauthorJan 03.2005 — lavalamp i know you can do that with javascript, infact thats what i know the most! and charles does it have to be in a <div>tag and does it have to be a submit? just asking...
Copy linkTweet thisAlerts:
@CharlesJan 03.2005 — Yes it has to be a submit button. Except in legacy versions of HTML, FORM elements cannot directly contain inline elements. You need some kind of block level element between the FORM and form control elements.
Copy linkTweet thisAlerts:
@ksourceJan 05.2005 — i know you can do a simple javascript onClick command and do a link but wouldnt it be nicer if we can make a button link for every browser?

ive seen it been done with images so can it be done with buttons?


code:
--------------------------------------------------------------------------------


<!--this is what i have so far-->

<a href=http://www.yahoo.com><input type="button" value="Yahoo!"></a>

--------------------------------------------------------------------------------[/QUOTE]


I have a solution:

&lt;form name="yahoo" action="http://www.yahoo.com"&gt;
&lt;input type="submit" value="Yahoo"&gt;
&lt;/form&gt;


I do not suggest this for permanant, but I think this will work until you find a more suitable code. I am almost certain this will work with all browsers, but I could be wrong. Someone please correct me if im wrong. Thanks.


hope I helped

-Kory
Copy linkTweet thisAlerts:
@CharlesJan 05.2005 — [i]Originally posted by ksource [/i]

[B]I have a solution:



&lt;form name="yahoo" action="http://www.yahoo.com"&gt;
&lt;input type="submit" value="Yahoo"&gt;
&lt;/form&gt;


I do not suggest this for permanant, but I think this will work until you find a more suitable code. I am almost certain this will work with all browsers, but I could be wrong. Someone please correct me if im wrong. Thanks.


hope I helped

-Kory [/B][/QUOTE]
It will work on every browser and you will find no more suitable code. But you should put the button itself inside a DIV element or such. Except in legacy versions of HTML, FORM elements cannot directly contain inline elements. You need some kind of block level element between the FORM and form control elements.
Copy linkTweet thisAlerts:
@ksourceJan 05.2005 — Can you explain to me what you mean about the form legalcy stuff?

Thanks.

-Kory
Copy linkTweet thisAlerts:
@CharlesJan 05.2005 — [i]Originally posted by ksource [/i]

[B]Can you explain to me what you mean about the form legalcy stuff?

Thanks.



-Kory [/B]
[/QUOTE]
Not FORM legacy, legacy versions of HTML. HTML has been through several versions. Before the December 1997 version it was valid for the FORM element to directly contain form elements. Since then you need a block level element between.

HTML, having reached a state of perfection with [url=http://www.w3.org/TR/html401/]HTML 4.01[/url], is now stable. No more versions will be issued.
Copy linkTweet thisAlerts:
@CharlesJan 05.2005 — By the way ksource, How's the Hooverball out there in Iowa these days? The weather here in Baltimore has been great and our team has been practicing, getting ready for Hooverfeast. This year we're comming in second in the six pound division for sure.
Copy linkTweet thisAlerts:
@ksourceJan 05.2005 — [i]Originally posted by Charles [/i]

[B]By the way ksource, How's the Hooverball out there in Iowa these days? The weather here in Baltimore has been great and our team has been practicing, getting ready for Hooverfeast. This year we're comming in second in the six pound division for sure. [/B][/QUOTE]




I dont think i've ever played Hooverball. What is is? Good luck at the Hooverfest though.

-Kory
Copy linkTweet thisAlerts:
@CharlesJan 05.2005 — [url=http://www.hooverassociation.org/hooverball.html]Hooverball[/url] is, I thought, the official sport of Iowa. The national championships are played each year during Hooverfest in West Branch.
Copy linkTweet thisAlerts:
@ksourceJan 07.2005 — [i]Originally posted by Charles [/i]

[B][url=http://www.hooverassociation.org/hooverball.html]Hooverball[/url] is, I thought, the official sport of Iowa. The national championships are played each year during Hooverfest in West Branch. [/B][/QUOTE]


It could be the official sport, i dont know. ? Im pretty occupied with baseball and hackey-sack. Maybe they should change the official sport to hackey-sack....

-- Kory
×

Success!

Help @age13kid spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...