...

View Full Version : Ccontrol content/stylsheet ref based on Browser



friscofrankie
09-19-2005, 10:43 AM
I am having some issues resolving Microsoft and "The Rest of The World" differences. There are quite a few...
Is there a way to ref different stylesheets based on the output from navigator.appName?
How far can I go in referencing different files for output stricly with client-side JavaScript? Maybe display completely different content depending on the browser?
This may be simple or impossible; all of my Java exp. is from hacking someone else's code and making changes as to suit evolving needs.
I am alos looking for a comprehensive reference on the web if anyone can point me. Books (in english) on Java are hard to comeby up here in the northern hills of Thailand.
While doing this with Perl, PHP or other server-side solutions is relatively simple, I am stuck with no server-side help for a next few months.

Any help is mch appreciated

FF

Spudhead
09-19-2005, 02:21 PM
It's not much of an answer, but would this be any help?

http://www.quirksmode.org/css/condcom.html

felgall
09-19-2005, 10:21 PM
You can't use navigator.appName to determine which browser someone is using because a lot of people using other browsers have it set to report itself as IE when it is asked.

The better way is to actually test if a particular feature is supported by the given browser before using it. That way it doesn't matter what the browser claims to be.

friscofrankie
09-20-2005, 07:46 AM
It's not much of an answer, but would this be any help?

http://www.quirksmode.org/css/condcom.html

let's see if
<!-->
<link rel="stylesheet" href="style/msie.css" type="text/css"/>
<!--[endif]-->>
works...
Yes and no. It links to the new style page. Also displays the <!--[endif]-->
in my page bears some tweaking. There are other issues in the way IE handles the rest of the code.
However, it [i]does give me some options and I will certainly use it in the future, with some tweaks to the parent code I could make this work. For now, I'm redirecting to two different pages based on what the browser reports its name as.



The better way is to actually test if a particular feature is supported by the given browser before using it. That way it doesn't matter what the browser claims to be

Thanks for that. So now all I have to figure out is how to ask the browser if parses XML, XHTML & CSS2 according to the W3C strict DTDs. I'm sure I'll figure it out. Be fun figuring it out; for now, in production, I'll let;

if(msie or wannabe_msie)
{
just load an msie page and forget it
}else{
load the real page
}


handle the issues.
My page works fine in Lynx and Links, so just going to have to code to a new lowest common denominator. I am just finding too many style/parse discrepencies to poll for each one.
Biggest problem?
Having to work in Windoze!!!
All day! :mad:
Gonna have to try IE for Unix on my slackware machine.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum