User | Post |
Rydain
Posts: 283/738 |
Jesper - Yep, I remember when that particular bit of news came out. Reactions were mixed, but I agree that they handled the issue intelligently so as not to encourage continued use of document.all or break this method of detecting a non-IE browser.
HyperHacker - Are you talking about getting references to objects that have their ID property set to something? If so, use document.getElementById(pass_the_id_here). This will work in all browsers that support the W3C DOM, i.e. virtually any modern graphical browser that you can think of (including IE 5 and up). |
HyperLamer
Posts: 1812/8210 |
What's the proper way to do that instead of using document.all? I use that often and Mozilla seems fine with it. |
Jesper
Posts: 1035/2390 |
Originally posted by Coby Hmm, yes, I could use that. Thanks! Anyway, what bug is that?
It's a known bug - you can't add style via Document Object Model calls; you have to use a special stylesheets call. Even then, the behavior when adding or modifying CSS live is buggy at best. I actually came across this when building the Edit Layout page for this very board. (That's why you can't Live Preview but have to reload the whole page - it would drop any stylesheets present in Live Preview.)
Rydain's suggestion is much simpler, though, and a lot easier to remember than mine. It should be noted that Firefox does have document.all to work with pages assuming IE and not even bothering to check, but still returns false on the check she provided. Which is deliberate and awesome. |
Rydain
Posts: 281/738 |
You should be able to just check for document.all, which is IE's proprietary DOM. To the best of my knowledge, no other browser will return true to if (document.all) |
Darth Coby
Posts: 901/1371 |
Hmm, yes, I could use that. Thanks! Anyway, what bug is that? |
Jesper
Posts: 1022/2390 |
If you're looking for a reliable way of checking for IE/Windows using Javascript that does NOT involve sniffing in the User Agent string (which other browsers can spoof), try this code snippet, that tries to look for a known IE/Windows bug.
isIE = false; var fooElement = document.createElement('style'); fooElement.type = 'text/css'; tn = document.createTextNode("foo"); try { fooElement.appendChild(tn); } catch(e) { if (e == "[object Error]") { // we have IE isIE = true; } } |
Darth Coby
Posts: 892/1371 |
Originally posted by Modereb Internet Explorer has 'MSIE x.x' (x.x being the version number, in my case, I see 'MSIE 6.0' in the string).
Also, I see you're using Javascript in PHP to get the client's User Agent, you can do it in PHP alone also...
if( stristr(getenv("HTTP_USER_AGENT"),'MSIE') ){ header('location:redirect.php'); } ?>
That would work? :O! Hmm, thanks! This makes my life a whole lot easier :p |
Modereb
Posts: 68/75 |
Internet Explorer has 'MSIE x.x' (x.x being the version number, in my case, I see 'MSIE 6.0' in the string).
Also, I see you're using Javascript in PHP to get the client's User Agent, you can do it in PHP alone also...
<? if( stristr(getenv("HTTP_USER_AGENT"),'MSIE') ){ header('location:redirect.php'); } ?> |
Darth Coby
Posts: 890/1371 |
I tried some script to check if you're using IE, but they also trigger IE when I'm using FireFox, this is my code: if (!isset($_COOKIE["wsreject"])) { $value = "Got rejected already. "; setcookie("wsreject", $value, time()+432000); echo " <SCRIPT LANGUAGE=JAVASCRIPT> <!-- var name = navigator.appName; if (name == \"Microsoft Internet Explorer\"); location.href = \"redirect.php\"; else name = "waii"; // -->>";
|