Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to navigate to a different page with JavaScript

Tags:

javascript

I'm currently redirecting users to a different page in C# with the following code;

Response.Redirect("somepage.aspx");

However, I'd like to do this in JavaScript instead.

like image 698
Krishna N Avatar asked Jan 23 '12 11:01

Krishna N


2 Answers

Basically you need:

function goURL() {
  location.href="http://example.com"  // change url to your's
}

additional java-script navigation options can be found in following link: http://www.sivamdesign.com/scripts/navigate.html

like image 189
james Avatar answered Oct 16 '22 13:10

james


Try this code below

<script language="JavaScript">

    function move() {
        window.location = "http://www.yourdomain.com";
    }

</script>
like image 25
Madhu Beela Avatar answered Oct 16 '22 14:10

Madhu Beela