Extracted from http://bbs.zdnet.com.cn/thread-108803-1-1.html
<Script language = "JavaScript">
<! --
If (window. Navigator. useragent. indexof ("MSIE")> = 1)
{
VaR ie1024 = "";
VaR ie800 = "";
VaR ie1152 = "";
VaR ieother = "";
Screenwidth (ie1024, ie800, ie1152, ieother)
} Else {
If (window. Navigator. useragent. indexof ("Firefox")> = 1)
{
File: // If the browser is Firefox
VaR firefox1024 = "";
VaR firefox800 = "";
VaR firefox1152 = "";
VaR firefoxother = "";
Screenwidth (firefox1024, firefox800, firefox1152, firefoxother)
} Else {
File: // If the browser is another
VaR other1024 = "";
VaR other800 = "";
VaR other1152 = "";
VaR otherother = "";
Screenwidth (other1024, other800, other1152, otherother)
}
}
Function screenwidth (css1, css2, css3, css4 ){
If (screen. width = 1024) & (screen. Height = 768 )){
Setactivestylesheet (css1 );
} Else {
If (screen. width = 800) & (screen. Height = 600 )){
Setactivestylesheet (css2 );
} Else {
If (screen. width = 1152) & (screen. Height = 864 )){
Setactivestylesheet (css3 );
} Else {
Setactivestylesheet (css4 );
}}}
}
Function setactivestylesheet (title ){
Document. getelementsbytagname ("Link") [0]. href = "style/" + title;
}
File: // -->
</SCRIPT>
This post is from zdnetchina Chinese Community Http://bbs.zdnet.com.cn, this post address: http://bbs.zdnet.com.cn/viewthread.php? Tid = 108803
[Explanation ]:
VaR ie1024 = "";
VaR ie800 = "";
VaR ie1152 = "";
VaR ieother = "";
Fill in the quotation marks separately. When you use IE, the resolution is 1024*768,800*600,115 2*864.
VaR firefox1024 = "";
VaR firefox800 = "";
VaR firefox1152 = "";
VaR firefoxother = "";
Fill in the quotation marks separately. When FF is used, the resolution is 1024*768,800*600,115 2*864.
VaR other1024 = "";
VaR other800 = "";
VaR other1152 = "";
VaR otherother = "";
Fill in the quotation marks separately. When you use other browsers, the resolution is 1024*768,800*600,115 2*864.
No resolution, only browser judgment
At E. Qiang's proposal, the compilation is as follows:Code. Implement automatic calling of different CSS based on the browser type.
Code:
<Script language = "JavaScript">
<! --
If (window. Navigator. useragent. indexof ("MSIE")> = 1)
{
File: // If the browser is IE
Setactivestylesheet ("default.css ");
} Else {
If (window. Navigator. useragent. indexof ("Firefox")> = 1)
{
File: // If the browser is Firefox
Setactivestylesheet ("default2.css ");
} Else {
File: // If the browser is another
Setactivestylesheet ("newsky.css ");
}
}
Function setactivestylesheet (title ){
Document. getelementsbytagname ("Link") [0]. href = "style/" + title;
}
File: // -->
</SCRIPT>
Explanation:
If the browser is Internet Explorer, default.css is used.
If the browser is firefox, default2.css is used.
If the browser is another user, newsky.css is used.
Usage: place it in This post from zdnetchina Chinese community http://bbs.zdnet.com.cn, this post address: http://bbs.zdnet.com.cn/viewthread.php? Tid = 108803