ride the whirlwinds
ride the whirlwinds

Reputation: 299

Blogger redirect happens after the full page loads first?

I am using a meta tag to redirect my Blogger page, however the redirect happens after the old Blogger then the redirect happens.

Is there any way to redirect without loading the old Blogger page completely first?

I am using the following code in the header section of my template:

<meta content='0;URL=&apos;http://newsite.com' http-equiv='refresh'/>     

Upvotes: 0

Views: 138

Answers (1)

Patartics Mil&#225;n
Patartics Mil&#225;n

Reputation: 4938

You should place your redirect code right after opening the head tag. This kind of JS redirect code generator will help you with this kind of situations. You should not use plain HTML meta redirect, but this all-in-one solution:

<!-- Pleace this snippet right after opening the head tag to make it work properly -->

<!-- This code is licensed under GNU GPL v3 -->
<!-- You are allowed to freely copy, distribute and use this code, but removing author credit is strictly prohibited -->
<!-- Generated by http://insider.zone/tools/client-side-url-redirect-generator/ -->

<!-- REDIRECTING STARTS -->
<link rel="canonical" href="http://newsite.com"/>
<noscript>
    <meta http-equiv="refresh" content="0;URL=http://newsite.com">
</noscript>
<!--[if lt IE 9]><script type="text/javascript">var IE_fix=true;</script><![endif]-->
<script type="text/javascript">
    var url = "http://newsite.com";
    if(typeof IE_fix != "undefined") // IE8 and lower fix to pass the http referer
    {
        document.write("redirecting..."); // Don't remove this line or appendChild() will fail because it is called before document.onload to make the redirect as fast as possible. Nobody will see this text, it is only a tech fix.
        var referLink = document.createElement("a");
        referLink.href = url;
        document.body.appendChild(referLink);
        referLink.click();
    }
    else { window.location.replace(url); } // All other browsers
</script>
<!-- Credit goes to http://insider.zone/ -->
<!-- REDIRECTING ENDS -->

It has search engine support, compatible with all browsers, and it avoids redirecting loops.

Upvotes: 1

Related Questions