Ipad下使用的是Safari浏覽器,在ie下的彈窗代碼在該浏覽器下無法執行。在已有的項目中如果需要在ipad下使用,必須對js進行修改。但如果是已開發的項目,最好的辦法是在最大限度上維持原有的代碼。是以最好是采用彈頁面的方式來實作div的效果。
從網上找到别人的部落格查到到這樣的一種js現成的解決方案,名字叫subModal,
相關的檔案有三個,一個javascript檔案,兩個樣式檔案。當然樣式檔案需要的話是要使用它的樣式。三個檔案的名稱分别是:
subModal.js
submodal.css
submodalstyle.css
使用到的方法有:
window.parent.hidePopWin(true); //加true應該是可以傳回參數
window.parent.hidePopWin();
找開視窗的方法:
showPopWin(contentpath+'/deptsjtoSelect.action', 630, 600, getReturnValue); //打開視窗的方法和ie下的彈出視窗有點類同,是以改動相對較少
//第四個參數代表回調方法 用于擷取傳回參數,寫法如下:
function getReturnValue(result){
alert(result);
}
最後一點要注意的:當時打開視窗的時候有個404錯誤,原來是少了個load頁面。還需要在web目錄下加個loading.html。裡面添加的标題可以顯示在彈出視窗之上。
示範的代碼下載下傳位址: http://www.360buyli.com/html/javascript/20121127/61.html
官方給出的說法:
<b>Where it works</b>
IE 6+
FireFox 0.9+
Safari
Opera 7+
Opera 7 works in a hacked fashion. Since Opera’s css support doesn’t include opacity I’m using a 24 bit transparent PNG file for the demo. If you don’t care about Opera you can comment this out and it will still work in FireFox, IE, and Safari. I like that method better since you have full control over the mask color and opacity right from the CSS file.