我正在處理一個老開發者的網站和代碼。刪除親子表格子窗口
有一個GLOBAL打印功能,傢伙寫道,基本上感覺到任何打開的新窗口(從任何方法)和「href.match」es域名...該腳本然後應用打印樣式表,如果需要並激發window.print。
這一切都是從每個頁面上的全局腳本完成的,幷包含一些其他功能。
我厭倦了寫每個頁面的案例添加,我想逃避這個功能。另外,如果我爲某個頁面編寫NOT子句,則在子窗口中的域內打開的任何後續頁面都將接收該打印函數。
有沒有辦法在這個新窗口中「繼續」繼承?基本上使這個窗口不是產生它的父親的孩子?
addEvent(window, 'load', function() {
var printBtn = document.getElementById('print-page');
if (window.opener && window.opener.location.href.match('domainnamehere')) {
var printCSS = document.createElement('link');
var a = document.getElementsByTagName('a');
printCSS.href = 'css/print.css'
printCSS.setAttribute('type', 'text/css');
printCSS.setAttribute('rel', 'stylesheet');
document.getElementsByTagName('head')[0].appendChild(printCSS);
for (var i = 0; i < a.length; i++) {
a[i].href="";
a[i].onclick = function() { return false; };
a[i].style.cursor = "default";
}
window.print();
} else if (printBtn){
printBtn.onclick = function() {
var printWindow = window.open(window.location, 'printwindow', 'resizable,width=800,height=800,scrollbars');
return false;
};
}
});
感謝約什...完善。 – 2011-02-10 20:41:39