我有这个网站在这里:www.bigideaadv.com/xsp我试图让一个视频弹出,当你点击观看视频链接。问题是我想要它扩大浏览器的宽度和浏览器的高度 - 242px。它在Firefox中正常工作,调整窗口大小时调整视频大小。在Safari和IE 7+中,没有骰子。变量正在使用调整大小上的新值更新,但不会更新CSS属性。它保持在视频的最初价值。任何人有任何想法?提前致谢。代码如下:视频窗口不适合屏幕宽度
function resize() {
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
//alert(viewportwidth);
//alert(viewportheight);
}
// 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
}
viewportheight = viewportheight - 242;
$('#sublime_video_wrapper_0').css('width', viewportwidth);
$('#sublime_video_wrapper_0').css('height', viewportheight);
$('#sublime_vixdeo_wrapper_0').css('z-index', '1003');
$('#slide1video embed').css('width', viewportwidth);
$('#slide1video embed').css('height', viewportheight);
$('#slide1video embed').css('z-index', '1002');
$('#slide1video').css('width', viewportwidth);
$('#slide1video').css('height', viewportheight);
$('#slide1video').css('z-index', '1001');
$('video.sublime').css('width', viewportwidth);
$('video.sublime').css('height', viewportheight);
$('video.sublime').css('z-index', '1000');
};
您是否尝试使用$(window).width()和$(window).height()来获取浏览器视口的维度? – 2012-03-05 17:41:58