我正在使用JavaScript代碼來檢查用戶瀏覽器是否啓用了彈出窗口阻止程序,該窗口在所有瀏覽器(IE中除外)中工作正常。 IE似乎沒有阻止從同一個域打開的彈出窗口。有什麼建議麼?阻止來自相同域的彈出窗口
var popUpStr;
var popUp = window.open("Name of popup which has same domain as the main windown", "", 'width=150, height=150, left=24, top=24, scrollbars, resizable');
if (popUp === null || typeof (popUp) == 'undefined' || typeof (popUp.location.hash) != "string" || (popUp === null && popUp.outerWidth === 0) || (popUp !== null && popUp.outerHeight === 0)) {
popUpStr = 'Popup Blocker is enabled';
} else {
popUp.close();
popUpStr = 'Popup Blocker is not enabled';
}
VAR popUpStr; (彈出窗口的名稱與主窗口的名稱相同),「」,'width = 150,height = 150,left = 24,top = 24,scrollbars,resizable'); (popUp === null || typeof(popUp)=='undefined'|| typeof(popUp.location.hash)!=「string」||(popUp === null && popUp.outerWidth === 0 )||(popup!== null && popUp.outerHeight === 0)){ popUpStr ='彈出式窗口阻止程序已啓用'; } else { popUp.close(); popUpStr ='彈出式窗口攔截器未啓用'; } – user3654109
一般來說,來自同一個域的彈出式窗口是您不想阻止的彈出式窗口...... –
請編輯它,而不是在評論中發佈代碼到您的問題中。我已經爲你更新了你的問題。 – j08691