我有這個網站在這裏: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