+5 votes
2.3k views
in Programming by (1.8k points)
Hello i want a button in which onClick a button by user redirect to a URL in JAVASCRIPT.

Thanks For answer.
closed

2 Answers

+1 vote
by (1.6k points)
selected by
 
Best answer

hey you can use this script 

<script>
function newUrl()
  {
  window.location.assign("http://URL_here")
  }
</script>
Html part button
 
<input type="button" value="visit url" onclick="newUrl()">
By this onClick a button by you can redirect to a URL.
+1 vote
by Expert (5.1k points)
<!DOCTYPE html>
<html>
<head>
<script>
function newDoc()
  {
  window.location.assign("http://www.google.com")//your url here
  }
</script>
</head>
<body>

<input type="button" value="Go" onclick="newDoc()">

</body>
</html>

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated