Forum Moderators: open

Message Too Old, No Replies

Html Buttons

         

J_RaD

1:38 am on Apr 25, 2008 (gmt 0)



i know how to make HTML buttons, but i want to make a button that jumps to an anchor.

surrealillusions

10:14 am on Apr 25, 2008 (gmt 0)

10+ Year Member



just place the image inside the a tag

<a href=#anchor><img src="button" alt="" /></a>

:)

penders

12:45 pm on Apr 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



i know how to make HTML buttons, but i want to make a button that jumps to an anchor.

If you are wanting to make an input (type="button") jump to an internal anchor then you could do something like:

<input type="button" value="Jump to Anchor" onclick="location.href='#anchor'">

However, this is not really what buttons are intended for and more importantly it is not usually what the user is expecting; as this is what anchors are for. And it relies on JavaScript to work.

surrealillusions suggestion is better.

rocknbil

4:05 pm on Apr 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Although it's still not the best solution, Javascript is not required. :-)

<form action="http://www.example.com/page.html#HERE"><input type="submit" value="Jump to HERE"></form>

This reverts to a get method for the form, so the result in the address bar will be

http://www.example.com/page.html?#HERE

Marshall

6:55 pm on Apr 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



J_RaD,

Instead of a button, why don't you just use a little CSS:

a {
color: #0F0;
background-color: #FF0;
border: 1px solid #000;
padding: 3px;
text-decoration: none;
}

This makes an ugly button, but you get the idea.

Marshall