Reputation: 45
What I want to do is to check through a conditional comment if a user is using IE6,7 or 8 and if he does then I want to load a different html file than my index.php.
I have been instructed to use a javascript like the one below:
$(document).ready(function(){
$(body).html('Please download firefox or chrome to view this site');});
and then use the normal conditional comment structure with tag including the js file, but for some reason this doesn't work.
Additionally as I said above I want to redirect the users in a new html file ex.main.html instead of index.php, if they are using IE as their browser. I do not want to use html code inside the comment, I want to somehow force the user be redirected to the new file.
Any ideas or guidance will be greatly appreciated. Thanks in advance.
Upvotes: 1
Views: 170
Reputation: 3242
span:only-of-type { display: none; } span { position: absolute; left: 50%; top: 50%; width: 300px; height: 300px; margin: -150px 0 0 -150px; background: black; }
…
<span>Dude, get a real browser!</span>
Upvotes: 0
Reputation: 11373
The simple solution, without JavaScript would look like this (put this in your <head>
):
<!--[if lte IE 8]><meta http-equiv="refresh" content="0;url=http://example.com/ie.html" /><![endif]-->
This would redirect the user to http://example.com/ie.html
(Just replace that part with the actual URL). Advantage of this solution: It does also work, if the user has deactivated JavaScript.
Upvotes: 1
Reputation: 47114
For a redirect in jQuery you could use:
$(window.location).attr('href', 'http://www.stackoverflow.com');
Or in plain JavaScript:
window.location.href='http://www.stackoverflow.com';
Upvotes: 2
Reputation: 382666
You can use jQuery.browser
method to determeine the browser being used.
Example:
if ($.browser.msie) {
alert("this is IE :(");
}
Upvotes: 1