<!--
var viewportwidth;
var viewportheight;
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined')
{
viewportwidth = window.innerWidth,
viewportheight = window.innerHeight
}
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0)
{
viewportwidth = document.documentElement.clientWidth,
viewportheight = document.documentElement.clientHeight
}
// older versions of IE
else
{
viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
viewportheight = document.getElementsByTagName('body')[0].clientHeight
}
document.write('<style>.desktop{ height:'+viewportheight+'px;}</style>');
//-->
выход
.desktop { height:687px;}
но его все окна просмотра. Я хочу это так: height = + viewportheight + - 30 = value. и я хочу применить к.desktop, как этот.desktop {height: value;}
Обновление 1
Я просто пытаюсь редактировать, как это.
if (typeof window.innerWidth != 'undefined')
{
viewportwidth = window.innerWidth,
viewportheight = window.innerHeight,
height = viewportheight - 30,
width = viewportwidth
}
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0)
{
viewportwidth = document.documentElement.clientWidth,
viewportheight = document.documentElement.clientHeight,
height = viewportheight - 30,
width = viewportwidth
}
// older versions of IE
else
{
viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
viewportheight = document.getElementsByTagName('body')[0].clientHeight,
height = viewportheight - 30,
width = viewportwidth
}
document.write('<style>.desktop{ width:'+width+'px ;height:'+height+'px;}</style>');
и его работа для меня. но если кто-нибудь здесь лучший способ, просто скажите мне.
Я редактирую это и свою работу для меня.
if (typeof window.innerWidth != 'undefined')
{
viewportwidth = window.innerWidth,
viewportheight = window.innerHeight,
height = viewportheight - 30,
width = viewportwidth
}
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0)
{
viewportwidth = document.documentElement.clientWidth,
viewportheight = document.documentElement.clientHeight,
height = viewportheight - 30,
width = viewportwidth
}
// older versions of IE
else
{
viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
viewportheight = document.getElementsByTagName('body')[0].clientHeight,
height = viewportheight - 30,
width = viewportwidth
}
document.write('<style>.desktop{ width:'+width+'px ;height:'+height+'px;}</style>'
Я не знаю о синтаксисе jquery/javascript. но я пытаюсь понять это.
я просто добавляю строку
height = viewportheight - 30,
width = viewportwidth
Ты пробовал
document.write('<style>.desktop{ height:' + (viewportheight - 30) + 'px;}</style>');
Я считаю, что это должно вычесть 30 из значения viewportheight