almightyegg Posted April 8, 2009 Share Posted April 8, 2009 I have a really irritating page that will only work in 1 of either Firefox and IE but never both no matter what Doctype, so I was wondering if there was a way to use 1 doctype for IE and another for FF?? Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/ Share on other sites More sharing options...
rhodesa Posted April 8, 2009 Share Posted April 8, 2009 um...i guess you could use a server side script to determine their browser from their HTTP_AGENT...but what i think the better option is to get it working for all browsers. what problems are you having? Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804498 Share on other sites More sharing options...
Yesideez Posted April 8, 2009 Share Posted April 8, 2009 The only way AFAIK to make the pages appear in all browsers is to make sure the CSS and/or HTML is written properly and where IE is concerned, you may have to add a minor "hack" to get it to work at all. You can add this into the HEAD part of your document to load an extra CSS file if IE is used. <!--[if IE]> <link rel="stylesheet" type="text/css" href="ie_hack.css" /> <![endif]--> Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804505 Share on other sites More sharing options...
almightyegg Posted April 8, 2009 Author Share Posted April 8, 2009 It's actually Firefox that's the problem... I have a chatroom script and it uses this code to show the latest posts: <!-- <textarea id="chatwindow" rows="19" cols="95" readonly></textarea><br> IE reads it fine in the DOCTYPE that I'v used for the rest of my side. In FF it displays: <!-- and then a big white square... Where it's meant to be black and have text in it :S Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804512 Share on other sites More sharing options...
Yesideez Posted April 8, 2009 Share Posted April 8, 2009 This is a comment: <!-- If you remove it - what happens? Where there's a <!-- there's usually a --> with it so you'll have to remove that as well. Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804520 Share on other sites More sharing options...
almightyegg Posted April 8, 2009 Author Share Posted April 8, 2009 there is no --> IE shows the correct thing plus a big white square and FF shows a big white square without <!-- Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804527 Share on other sites More sharing options...
Yesideez Posted April 8, 2009 Share Posted April 8, 2009 Can you post the HTML making this please? I'm intrigued! Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804535 Share on other sites More sharing options...
almightyegg Posted April 8, 2009 Author Share Posted April 8, 2009 // above here is just general tags not to do with this (and the doctype etc..) <div id="content"> <p id="chatwindow"> </p> <!-- <textarea id="chatwindow" rows="19" cols="95" readonly></textarea><br> <input id="chatnick" type="hidden" value="<a href='/player/view.php?id=<? echo "$mem[id]'>$mem[username]</a>"; ?>"> <input id="chatmsg" type="text" size="60" maxlength="80" onkeyup="keyup(event.keyCode);"> <input type="button" value="Post" onclick="submit_msg();"></div> <br><br><br><br><br> </div> <? include 'stats.php'; ?> </body></html> <script type="text/javascript"> /* Settings you might want to define */ var waittime=0; /* Internal Variables & Stuff */ chatmsg.focus() document.getElementById("chatwindow").innerHTML = "loading..."; var xmlhttp = false; var xmlhttp2 = false; /* Request for Reading the Chat Content */ function ajax_read(url) { if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); if(xmlhttp.overrideMimeType){ xmlhttp.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp) { alert('Giving up Cannot create an XMLHTTP instance'); return false; } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4) { document.getElementById("chatwindow").innerHTML = xmlhttp.responseText; zeit = new Date(); ms = (zeit.getHours() * 24 * 60 * 1000) + (zeit.getMinutes() * 60 * 1000) + (zeit.getSeconds() * 1000) + zeit.getMilliseconds(); intUpdate = setTimeout("ajax_read('chat.txt?x=" + ms + "')", waittime) } } xmlhttp.open('GET',url,true); xmlhttp.send(null); } /* Request for Writing the Message */ function ajax_write(url){ if(window.XMLHttpRequest){ xmlhttp2=new XMLHttpRequest(); if(xmlhttp2.overrideMimeType){ xmlhttp2.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp2) { alert('Giving up Cannot create an XMLHTTP instance'); return false; } xmlhttp2.open('GET',url,true); xmlhttp2.send(null); } /* Submit the Message */ function submit_msg(){ nick = document.getElementById("chatnick").value; msg = document.getElementById("chatmsg").value; if (nick == "") { check = prompt("please enter username:"); if (check === null) return 0; if (check == "") check = "anonymous"; document.getElementById("chatnick").value = check; nick = check; } document.getElementById("chatmsg").value = ""; ajax_write("w.php?m=" + msg + "&n=" + nick); } /* Check if Enter is pressed */ function keyup(arg1) { if (arg1 == 13) submit_msg(); } /* Start the Requests! */ var intUpdate = setTimeout("ajax_read('chat.txt')", waittime); </script> Also, I forgot to mention, they work fine when there's no doctype but my DIVs don't work at all then :S Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804540 Share on other sites More sharing options...
rhodesa Posted April 8, 2009 Share Posted April 8, 2009 i'm confused on the <!-- are you trying to print those characters? if so it should be: <!-- <textarea id="chatwindow" rows="19" cols="95" readonly></textarea><br> or is this some sort of html trick? Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804545 Share on other sites More sharing options...
Yesideez Posted April 8, 2009 Share Posted April 8, 2009 Now that's got me stumped! The <!-- is definitely a comment so I'd say that the browser would be sort of ignoring the rest of the file because there's no closing --> but stranger things have been known to occur. Have you got Firebug installed for Firefox? The only thing I can suggest is use that to examine the page in the browser and see how things are being constructed as Firebug will remove anything that isn't valid. Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804548 Share on other sites More sharing options...
Yesideez Posted April 8, 2009 Share Posted April 8, 2009 I just found this little gem elsewhere on here that you might find useful... http://www.phpfreaks.com/blog/testing-legacy-versions-of-internet-explorer Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804580 Share on other sites More sharing options...
almightyegg Posted April 8, 2009 Author Share Posted April 8, 2009 The <!-- is being used as something else, don't ask me what, it was a premade script... By that link you sent, this should work: <!-- [if IE]> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <![endif]--> <!-- [if !IE]> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <![endif]--> Yet IE doesn't work now, FF does Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804723 Share on other sites More sharing options...
almightyegg Posted April 8, 2009 Author Share Posted April 8, 2009 GOT IT! There was an extra space in the <!--[if IE]> thing Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/153155-solved-is-there-a-way-of-using-different-doctypes-for-different-browsers/#findComment-804728 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.