Redirect Methods

Redirecting is very important method in web programming. Yes, Now we gonna see how to use Jquery & PHP default redirect functions in development.

Method 1: Redirection using Javascript
For any reason if you want to implement Redirection in your web application using Javascript. Then use this method. Jquery is not necessary to implement this way.

// It work same as HTTP redirect
window.location.replace("http://webexpertlabs.com");

// work same as above as it works for every browser
window.location.href = "http://webexpertlabs.com";

// alternative way and sometimes not compatible to some browser
window.location = "http://webexpertlabs.com";

Method 2: Redirection using Jquery
If you want to redirect your webpage using Jquery then you can follow this way.
Jquery library is needed to implement this feature.

var url = "http://webexpertlabs.com";
$(location).attr('href',url);

Method 3: Redirection using PHP
If you need to implement server side redirection in your Web application then you can use this way. Jquery has nothing to do in this method to Redirect Webpage using PHP

<!--?php
header("location:http://webexpertlabs.com");
?>
Enjoy!!! Hopefully this simple script helped you with your web development.
Source : webexpertlabs

 

Post a Comment

Post a Comment (0)

Previous Post Next Post