This script was designed for use in metatags of your target document, inside an iframe to load large ads or other what-nots, after the actual body of the article has had time to fully load. Out of respect for the visitor's time, and convenience to leave the site when they want to, and returning immediately to their point of origin.
They should already be reading the article they came for, when the iframe begins loading.
Using a script like this, I guarantee your visitors will respect you the morning after.
WHY I CHOSE THE FINAL CODE SOLUTION (ABOVE)
From emails over the weekend:
"The traditional method for redirecting a page is to use a "refresh" meta-tag. The biggest problem with using this method is that the redirection page is included in the visitor's page history, and thus when the user selects the "back" button and reaches the redirection page again they will be immediately returned to the redirection-target page".
Sharon: and those visitors may not want to return to the site.
COMMENT ON PROBLEMS IN SOME JAVASCRIPT FOR RE-DIRECTION
Using a plain metatag, the frame loads immediately, and then the redirect refreshes to the frame of animated gifs.
Click on the back button and see where you go however.
I need a script where they can hit the back button and get back to point of origin if they want, by-passing the metatag refresh in their browser.
- If I set those large graphics to initiate immediately, it drags down the loading time and our visitors don't like that. I've noticed an increase in our traffic since delaying the amount of time for the graphics to load. I placed a meta refresh tag into a tiny html file, that after 15 or 20 seconds, it loads the actual html page containing the graphics with delayed loading.
- The drawback is, when the visitor clicks on their back button to return to their point of origins, they won't return there --the "loading page with the meta refresh tag" is brought up, and it'll send them right back to graphics loading.
I did find one script on the web which erases that loading page out of the browser's history, so when the visitor clicks on their back button, they can go straight back to where they first entered... but the drawback is, despite the script supposedly allowing x*1000 (each x is suppose to be a second) -- it disregards that, and immediately loads the page, and that totally defeats the purpose of allowing the page to load before the graphics.
A CORRECT JAVASCRIPT
Here is a partially correct script for this *specific* problem (above). <-- small correct script, still the problem with time.
<script>
<!--
var version = parseInt(navigator.appVersion)
// replace is supported
if (version>=4 || window.location.replace)
window.location.replace("target.html")
else
window.location.href = "target.html"
// -->
</script>
However, he does not cover how to get the javascript to delay loading. It still loads immediately.
META HTTP-EQUIV="Refresh" CONTENT="2; http://www.insideDHTML.com/home.asp"
the 'content="2' is suppose to set the amount of seconds before redirecting, normally it will, but not with the javascript in the head.
Yep, my browser button says "Back to Google", but the image frame loaded immediately, no delay. That also defeats the purpose.
Concerning advice located here.
The information is *perfect*, except... how to set delayed loading time?
This code automatically refreshes to the page that's targeted, but gives no delay time. I noticed in my search all over the web a majority of webmasters seem to overlook that aspect.
If our visitors want to click on the back button and leave our website, I don't want to trap them with a disabled back button. I want them to be able to return right back to wherever they came from in one click. Having to make multiple clicks on the back button is aggravating and confusing).
So, how to set a time delay in the javascript?
As a last resort... post in a forum and be specific of what you're after.
Above all, if you're a webmaster please always spell out the complete code and not parts of it. *please*. That was part of my difficulty. It took about three days or more surfing the web, piecing together what a person should do for this particular javascript. Webmasters were posting only portions of the Javascript.
THE CODE REQUIRED TO FIX THE PROBLEM
This is the code required to fix the problem.
Posted by Kaleb.
<script
type="text/javascript">
<!--
setTimeout("location.replace('target.html')",15000);
-->
</script>
Browsers with javascript disabled may have trouble, (the frames should load with the meta-refresh tag, but they'll have to click, click, click to get back out) but most users apparently do have javascript enabled.
I tinkered with the script, using the javascript I picked up at webmasterworld.com combined with the script from insidedhtml.com
insidedhtml site states: We recommend one of two solutions. First, we have a short script that solves this problem. JavaScript 1.1 (supported by Netscape 3.0 browser and later and Internet Explorer 4.0) added a method to the location object, replace.
The purpose of the explanation is to cover browsers that do not support JavaScript 1.1. For those browsers, the navigation is not automatic and this page is added to the history. However, since the navigation is manual, the user can easily back through this page. For browsers that support JavaScript 1.1, it is as if this page never existed. The second solution is a compromise for sites that believe they must have automatic redirection whenever possible. For those sites, we use a combined approach...
This seems to work perfectly too:
<script>
<!--
var version =
parseInt(navigator.appVersion)
// replace is supported
if (version>=4 || window.location.replace)
setTimeout("window.location.replace('target.html')",15000);
else
window.location.href = "target.html"
//
-->
</script>
Now go one more, and tinkering with what http://grizzlyweb.com states about wrapping your meta-refresh tag
in <noscript></noscript>
Grizzly Webmaster's site states: We do use the "refresh" meta-tag nested in a <noscript> block as a backup method to the JavaScript for browsers that do not support JavaScript at all.
<noscript>
<meta http-equiv="refresh" content="15; url=target.html">
</noscript>
The Script Looks Like This
<noscript>
<meta http-equiv="refresh" content="15; url=target.html">
</noscript>
<script>
<!--
var version = parseInt(navigator.appVersion)
// replace is supported
if (version>=4 || window.location.replace)
setTimeout("window.location.replace('target.html')",15000);
else
window.location.href =
"target.html"
//
-->
</script>
Our visitors should have faster loading pages, and if they want to leave, they simply click one time on the back button (instead of back through meta refresh loading pages). This is way cool.
Message awaits moderator approval
RELATED ARTICLES
Copyright Protection and the Law
Understanding copyrights, and what can and cannot be used when using the intellectual property of another author.
Frames, Perfect Alignment on iframe and Rotating Banner ScriptHow to create iframes that align perfectly to the edge, and can rotate banners.
I have found this to be a very useful set of scripts. The frame is instructed to load a random target (which can be any number of ads or what-nots), including large ads, but still with delayed loading time and without interfering with the visitor leaving the site with one click on the back button (utilizing the script on the page you're currently on). This script has also proven invaluable with AdSense's "alternative inhouse" ads, it's an *.shtml format, small, clean and free. Works perfect inside an iframe! for rotating ads.
Drop Down Menus Inside Frame - Setting Style and Opening in Same Browser
Code to make a drop down menu inside a frame which will open the targeted page inside the same browser. Setting the look and style of your drop menu.
ASCII - HTML - Unicode Character Entities Chart
Includes thousands of html code for standard ASCII entity equivalents, and foreign languages; arabic, greek, etc, decorative characters and mathematical characters, with instructions on using the number pad and ALT.