0

how can you go about making a simple redirect script with javascript(no jquery needed) to rediret from one webpage to another?

header('Location: http://www.myredirectwebpage.com/');

but with javascript?

James
  • 1,260
  • 13
  • 25

3 Answers3

0

Here is a simple way of redirecting a webpage and no jquery is needed!!

<html>
    <head>
    <script>
    function redirect() {
        window.location.assign("http://www.mywebsiteurl.com")
    }
    </script>
    </head>
    <body>

    <input type="button" value="clik here ... redirect" onclick="redirect()">

    </body>
    </html>
James
  • 1,260
  • 13
  • 25
0
<script>
window.location.href = 'http://www.myredirectwebpage.com/';
</script>
MaggsWeb
  • 3,018
  • 1
  • 13
  • 23
  • While this code snippet may solve the question, [including an explanation](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – Lynn Crumbling Sep 03 '15 at 21:39
0

Here is a simple way to redirect from webpage1 to webpage2

<input type='button' onclick='Redirect()' value='Redirect To WebPage2' />

<script type='text/javascript'>
  function Redirect()
  {
   window.location = 'http://www.webpage2.com';
  //-- You can also use window.location.href = 'http://www.webpage2.com'; 
  }
</script>