Forum Moderators: open
1. First, I create a variable "agt", which sets the userAgent string to lower case.
2. The next line finds the starting position of the string "m-a-c" in the agent string. If that starting position is not equal to -1 (in other words, if the string is actually there) then the variable "is_mac" is set to a Boolean (true or false) value of "true".
3. Next, set another variable called "version" to be just the integer part of the navigator.appVersion string. This will truncate the decimal part of the version number.
4. Look to see if the string "m-s-i-e" appears in in the agt string (similar to step 2). If it's there (again, not equal to -1), then is_ie is set to "true".
5. Set a new variable to combine the "true or false" value of "is_ie" and the statement "version = 5". This gives us the "true or false" value for is_ie5. According tom Boolean operation, "is-ie5" will be true only if BOTH values are true.
6. The final step. If both "is_mac" and "is_ie5" are true, then replace the current location. I used the replace() method so that the user's Back Button will stay intuitive.
var agt=navigator.userAgent.toLowerCase();
var is_mac = (agt.indexOf("mac")!=-1);
var version = parseInt(navigator.appVersion);
var is_ie = (agt.indexOf("msie")!= -1);
var is_ie5 = (is_ie && (version = 5));
if (is_mac && is_ie5) {location.replace("alternate_page.html")}
Do I just put this in my head tag?
<script language=JavaScript>
var agt=navigator.userAgent.toLowerCase();
var is_mac = (agt.indexOf("mac")!=-1);
var version = parseInt(navigator.appVersion);
var is_ie = (agt.indexOf("msie")!= -1);
var is_ie5 = (is_ie && (version = 5));
if (is_mac && is_ie5) {location.replace("alternate_page.html")}
</script>
kelly001, your code works, but it "breaks" the Back Button for your visitor. I'd suggest changing this line:
top.location.href = "new-iframe-page.html";
to read like this:
top.location.replace("new-iframe-page.html");
Glad you've got your solution.