Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
0 user currently in Programming. | 3 guests |
Acmlm's Board - I2 Archive - Programming - Identifying IE? [Javascript] | | | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
Darth Coby Vire Dacht je nou echt dat het over was? Dacht je nou echt dat ik gebroken was? Nee toch? Nou kijk eens goed op uit je ogen gast. zonder clic heb je geen kloten tjap... bitch Level: 55 Posts: 890/1371 EXP: 1240774 For next: 73415 Since: 03-15-04 From: Belgium Since last post: 2 days Last activity: 9 hours |
| ||
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 " < < var name = navigator.appName; if (name == \"Microsoft Internet Explorer\"); location.href = \"redirect.php\"; else name = "waii"; // (edited by Coby on 10-13-04 04:39 PM) (edited by Coby on 10-13-04 04:39 PM) |
|||
Modereb Paragoomba Level: 15 Posts: 68/75 EXP: 14749 For next: 1635 Since: 06-04-04 Since last post: 350 days Last activity: 339 days |
| ||
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 Vire Dacht je nou echt dat het over was? Dacht je nou echt dat ik gebroken was? Nee toch? Nou kijk eens goed op uit je ogen gast. zonder clic heb je geen kloten tjap... bitch Level: 55 Posts: 892/1371 EXP: 1240774 For next: 73415 Since: 03-15-04 From: Belgium Since last post: 2 days Last activity: 9 hours |
| ||
Originally posted by Modereb That would work? :O! Hmm, thanks! This makes my life a whole lot easier :p (edited by Coby on 10-14-04 03:48 AM) |
|||
Jesper Busy, busy, busy. Level: 69 Posts: 1022/2390 EXP: 2856000 For next: 13743 Since: 03-15-04 From: Sweden. Since last post: 176 days Last activity: 79 days |
| ||
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 Vire Dacht je nou echt dat het over was? Dacht je nou echt dat ik gebroken was? Nee toch? Nou kijk eens goed op uit je ogen gast. zonder clic heb je geen kloten tjap... bitch Level: 55 Posts: 901/1371 EXP: 1240774 For next: 73415 Since: 03-15-04 From: Belgium Since last post: 2 days Last activity: 9 hours |
| ||
Hmm, yes, I could use that. Thanks! Anyway, what bug is that? |
|||
Rydain Ropa Blaze Phoenix Runs With the Dragon Within Level: 42 Posts: 281/738 EXP: 490056 For next: 31306 Since: 03-15-04 From: State College, PA Since last post: 6 days Last activity: 8 hours |
| ||
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) | |||
Jesper Busy, busy, busy. Level: 69 Posts: 1035/2390 EXP: 2856000 For next: 13743 Since: 03-15-04 From: Sweden. Since last post: 176 days Last activity: 79 days |
| ||
Originally posted by CobyIt'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. |
|||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 1812/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
What's the proper way to do that instead of using document.all? I use that often and Mozilla seems fine with it. | |||
Rydain Ropa Blaze Phoenix Runs With the Dragon Within Level: 42 Posts: 283/738 EXP: 490056 For next: 31306 Since: 03-15-04 From: State College, PA Since last post: 6 days Last activity: 8 hours |
| ||
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). |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Programming - Identifying IE? [Javascript] | | | |