Click to See Complete Forum and Search --> : onclick event


idiot
09-17-2003, 08:53 AM
HI,
im having some trouble using the onclick event.
When a button is clicked i need it to open a new link in the same window. This is what ive used, but when I test it and click on the button it does nothing, the page sort of freezes and then the screen goes empty.

<input type="button" name="confrm" id="confrm" value="Confirm Booking" onclick="openlink()">

<script>
function openlink{
document.open("url")
}
</script>
appreciate any help
THnx

pyro
09-17-2003, 08:55 AM
What's wrong with a regular link, which will be accessible to all users?

<a href="http://www.w3c.org">W3C</a>

Though if you must:

<input type="button" value="go" onclick="window.location.href='http://www.w3c.org';">

AdamGundry
09-17-2003, 10:49 AM
How about this (still a button, but accessible without JS):

<form action="http://www.w3c.org" method="GET">
<button type="submit">Go</button>
</form>

Adam