/* ----------------------------------------------- Title: 處理網頁視窗的相關函式 Designer: Evan Tung Modify Date: 2007/4/10 ----------------------------------------------- */ /* 跳轉到另一個網頁 ----------------------------------------------- */ function changeURL(url) { window.location.href = url; } /* 產生新的彈出視窗 ----------------------------------------------- */ function makePopup(url,width,height,overflow) { if(width > 800) {width = 800 ;} if(height > 600) {height = 600 ;} if(overflow == '' || !/^(scroll|resize|both)$/.test(overflow)){ overflow= 'both'; } var win = window.open(url,'','width=' + width + ',height=' +height + ',scrollbars=' + (/^(scroll|both)$/.test(overflow) ? 'yes' : 'no') + ',resizable=' +(/^(rezise|both)$/.test(overflow) ? 'yes' : 'no') + ',status=yes,toolbar=no,menubar=no,location=no,resizable=no' ); return win; } /* 產取得網頁視窗的捲動位置 ----------------------------------------------- */ function getScrollingPosition(){ var posttion = [0,0]; if(typeof window.pageYOffset != 'undefined'){ position = [window.pageXOffset,window.pageYOffset]; } else if(typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop >0){ position = [document.documentElement.scrollLeft,document.documentElement.scrollTop]; } else if(typeof document.body.scrollTop != 'undefined'){ position = [document.body.scrollLeft,document.body.scrollTop]; } return position; } /* 取得網頁視窗中可用空間的大小 ----------------------------------------------- */ function getViewportSize(){ var size = [0,0]; if(typeof window.innerWidth != 'undefined'){ size = [window.innerWidth,window.innerHeight]; } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){ size = [document.documentElement.clientWidth,document.documentElement.clientHeight]; } else{ size = [document.getElementsByTagName('body')[0].clientWidth,document.getElementsByTagName('body')[0].clientHeight]; } return size; }