Wednesday, June 12, 2013

How to do HTTP redirect to a URL using JavaScript

Follow the simple steps to do HTTP redirect to a URL using JavaScript.
<script type='text/javascript'>
forwardUrl(); // calling the function to redirect
function forwardUrl() {
     window.location.href = '';
Change the URL to your url to forward. And call the function to forward.

And we can send the parameters along with the url using this script also.
<script type='text/javascript'>
var value1 = 10;
var value2 = 'testing';
     window.location.href = ''+value1+'&param2='+value2;
This script will forward from current page to requested URL location along with the 2 GET parameters param1 and param2. we can use this 2 parameters where ever we need.
Use $param1 = $_GET['param1'] and $param2 = $_GET['param2'] to get the values in the page1.php.

Thank you...

No comments:

Post a Comment