SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: Browser Specific Work-around
-
Jan 25, 2003, 10:09 #1
Browser Specific Work-around
I found something that might be useful to some people. I notice that some people are concerned with ensuring their pages are viewed as intended on various browsers. This is probably not a bad idea as it shows dedication and the desire to make things work more completely. Validating to the latest standards is also a good idea. I don't put a page up until it validates xhtml 1.1
The following might take a bit to set up, but once done, I believe designers can establish a new set of templates for themselves. I am sure something like this is located on the forum already, but I still read a lot about "browser issues" so maybe it warrents a relook.
</preface>
<meatandpotatos>
One way to get around all the browser compatibility issues is to use a different style sheet for each browser. You can do this by adding a JavaScript block such as the one below to the <head> section of your HTML document(s):
<script language="JavaScript">
<!--
if(-1 != navigator.userAgent.indexOf("MSIE"))
{
// Internet Explorer
document.write('<link rel="stylesheet" type="text/css" href="ie.css">');
}
else if (-1 != navigator.userAgent.indexOf("Mozilla"))
{
// Netscape
document.write('<link rel="stylesheet" type="text/css" href="netscape.css">');
}
else
{
// other
document.write('<link rel="stylesheet" type="text/css" href="other.css">');
}
//-->
</script>
-
Jan 25, 2003, 11:26 #2
- Join Date
- Mar 2002
- Location
- Svíþjóð
- Posts
- 4,080
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Might be useful...
...but is this what we want to do, use a different style sheet for each browser?
My policy is; ignore non-standard browsers
-
Jan 25, 2003, 11:44 #3
That is certainly valid.
The script is a valid option if you wish to find a more organized way too make your site display consistantly across various browsers.
It all depends on what the designer wishes to accomplish.
Validate to the most current standard
Make site display as intended on every browser possible
Make site display on only a couple of current browsers
Don't care if anyone ever see's my site, it's for me only!!!
There are different ways to accomplish just about anything with markup languages. There are the hard ways, easy ways, work-around ways, hack ways, compliant ways. The javascript posted above offers a possible compliant method that certainly seems like a well thought-out and organized option. For the meantime, it might be useful while consistant standards and universal browser architectures are being developed and scripts like this aren't necessary. Seeing as how it was impossible to predict that standards would be so complex for markup languages, it's not that unreasonable to implement workable and solid solutions until we live in a perfectly wide web world
</lecture>
-
Jan 25, 2003, 13:29 #4
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've used that code before. I like it too
Content Writing Service - Get custom SEO articles for 10$
-
Jan 26, 2003, 07:20 #5
- Join Date
- Jan 2003
- Location
- Hampshire UK
- Posts
- 40,556
- Mentioned
- 183 Post(s)
- Tagged
- 6 Thread(s)
Hi,
While I think it's a good idea to make your site as compatible as possible, in your example won't you end up with loads of stylesheets. I believe there are over 50 different browsers out there.
It isn't just different browsers you need to accomodate its each different version of each browser that is different also. e.g.IE5 has a completely broken box model whereas IE6's box model is more or less ok.
Also you could argue that using javascript is less compatible as I believe that at the last count 15% of users have javascript turned off. Which means that you would loose more users than if you just code for IE5 & 6 .So you will also need to set up a default stylesheet anyway.
I don't know what the answer is but I do feel that we should be programming for the future and not the past. If your site is programmed to standards then eventually (with any luck) all new browsers will be equal and pages will start to look the way they were intended.
Anyway I've borrowed your script in case I'm wrong
Paul
Bookmarks