Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>document.write browser specific response

document.write browser specific response

Outshine
12-02-2004, 06:04 PM
I've searched around quite a bit on here and other forums and haven't been able to find what I'm looking for.

I'd like to be able to detect the user browser and document.write out a specific stylesheet link for different browsers.

The reason I'm forced to do this is because it appears that IE and Netscape view pixels differently. If I use 700 pixels in IE to line something up I need to use 690 to line it up in Netscape. Of course, if I use 690 for Netscape, it's too short for IE.

Has anyone else experienced this problem and is my approach (using document.write for specific browsers) the correct approach?

Thanks for your help!

Luke

Outshine
12-02-2004, 06:18 PM
Of course as soon as I ask for help I get it working. For any other rookie's that are wondering how it was done, paste the following code between the <head> tag's:

<script language="JavaScript"><!--
browser_version= parseInt(navigator.appVersion);
browser_type = navigator.appName;

if (browser_type == "Microsoft Internet Explorer" && (browser_version >= 4)) {
document.write("<link REL='stylesheet' HREF='http://www.codingforums.com/archive/index.php/ie.css' TYPE='text/css'>");
}

else if (browser_type == "Netscape" && (browser_version >= 4)) {
document.write("<link REL='stylesheet' HREF='http://www.codingforums.com/archive/index.php/netscape.css' TYPE='text/css'>");
}

// --></script>

I would still be interested to hear if anyone else has experienced problems with netscape and ie's differing interpretations of pixel width/height.


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

Command Buttons & Text Field Data Entry?
validating form field if radio button is checked
Question- Please HELP !
how do you create a pop-up window?
window.back() Fails in IE
Querying a page without reloading current page
button value not being sent

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics