Bloke > JavaScript > JavaScript Version Selector
These scripts will help you to determine if you are using a
version that is compatible with what you are trying to do.
I just have the most popular requests. If there is one that you
would like, let me know and I'll add it.
The following is generated from a script, it will cause the browser to
make a link to different pages depending on what kinda of browser they have.
LinkOnVersion
The above example is done using:
<SCRIPT>
LinkOnVersion("Click here for a version dependent page","basic.html", "version2.html","version3.html","version4.html","version5.html");
</SCRIPT>
The regular usage is:
<SCRIPT>
<!--
LinkOnVersion(html, basicurl, url2, url3, url4, url5);
-->
</SCRIPT>
where
- html is the html that you want to link
- url2 is the version 2 page
- url3 is the version 3 page
- url4 is the version 4 page
- url5 is the version 5 page
- basicurl is the most basic page that should work on all browsers
- the urls can the same url...
eg
LinkOnVersion("Go There", basic.html, basic.html, basic.html, cool.html, cool.html);
RedirectOnVersion
If the version is two low, go to some other page. Eg:
<SCRIPT>
<!--
RequiresVersion2("lowurl.html");
-->
</SCRIPT>
In general:
- RequiresVersion2(url);
- RequiresVersion3(url);
- RequiresVersion4(url);
where
- url is the url to goto if the requirement is not met.
I created a Test Page that needs to be a version 4
browser, if you view this page without a version 4 browser, it will send
you elsewhere.
How To
- Include version.txt in the HEAD section of your document.
- Call the functions as shown in the above example.
- View the source of this document for an example.
Got JavaScript questions?
Maybe my JavaScript Board has the answers?
Cameron Gregory - cameron@bloke.com