There is a question, "On a same domain, how to redirect all page to the specified page, but don't do that at the spesific page or doesn't happen anything at page requested, let do this by javascript".
To do that, you need to include some words of the url page, not all but just some.
Example :
Target page URL: http://yourdomain.com/my-redirect-page.html
You can use : my-redirect-page.html, or redirect-page.html to recognized the redirect page by putting that a part of url to the javascript.
Also you can set a timmer to execute how long the redirect process will work, for example, will go to a specific page automatically after 15 seconds, so the previous page does not lose a visitor.
How to make redirect from a spesific url
Target page URL: http://yourdomain.com/my-redirect-page.htmlthe scripts used:
if (window.location.href.indexOf('my-redirect-page.html') > -1){
// do nothing
} else {location.href('http://yourdomain.com/url-destiny.html')
}
With this script, all of page will be redirect to spesific page, but "Do nothing" at the target page in same domain
Hot to make redirect page by timmer
You might don't want to lose visitors to your blog or website, then if you use the redirect page, preferably using a timer so that visitors will be redirected to another page within a certain time, say after 30 seconds.The script is :
if (window.location.href.indexOf('my-redirect-page.html') > -1){
// do nothing
} else {
setTimeout(function() {
location.href('http://yourdomain.com/url-destiny.html')
} , 30000);
}
How to make URL destination page to the all page, but hide it on destination page
Same as the script for the redirect page by timmer, after 30 sec he page will covered by frame, but at "else" condition you have to change the script to make some element.The script is :
if (window.location.href.indexOf('my-redirect-page.html') > -1){
// do nothing
} else {
setTimeout(function() {
document.writeln("<div style='width: 100%; height: 100%; background: #000; color: #fff'><div style='padding: 20px; text-align: center'>Your content here <a href='http://yourdestinationurl.com'>Read more...</a></div></div>")
} , 30000);
}
Hop this help.
Labels: blog template, Blogger, English Blog, Java, javascript, PHP, Webmaster