Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button to open a link

Status
Not open for further replies.

mark01

Technical User
Jan 17, 2001
600
US
Hello, I'm trying to get a button to display open a link.
<button>ClickMe</button> is what I have so far. I but an <a href=" before it, and it sort of works, but not all the time.

Is there a better way of doing this?

Thanks
 
You could use Javascript, or use a submit button and surround it with a form?

Code:
<button OnClick="window.open(....)">Click Me</button>

or

<form action="pagetogoto.html" method=post>
<input type=submit value="Click Me">
</form>


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks!

I got the above code to work, but had to adjust it a little:
<button OnClick=window.open("....")>Click Me</button>

It opens in a new window. Does anyone know how to make it open in the same window?

Thanks
 
Nevermind. Found it.. I used window.navigate to make it work..

Thanks for the help!
 
document.location = "newurl.html" is the most common way to redirect a page, but for any further javascript questions please post them in that forum: forum216

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
Be aware that search engines will not be able to follow links done in this way, so if this for an internet site and you want to get it Googled, don't do this.

Note that with CSS to style the borders, you can make a regular <a> link look like a button.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top