Thursday, January 17, 2013

JavaScript onload Redirect to Another Page

Using JavaScript onload Event We can ask JavaScript to redirect to another page.

Add following JavaScript redirect code to head section in You’re Web page.

<script type="text/javascript">
        window.onload = auto_redirect;
        function auto_redirect() {
            var url_redirect = "www.ccnaq.blogspot.com";
            window.location = url_redirect;
        } 
</script>


In Above Example first we ask JavaScript to perform a function call auto_redirect in window.onload Event.

Then in auto_redirect function we create variable name redirect _url and assign url of the page we want to redirect and finally we redirect page using JavaScript window.location Object

No comments:

Post a Comment