JavaScript/Cross Browser のバックアップ(No.1) |
|
[変更前 (IE専用)]
function showDialog() { var url = "popup.html"; var features = "dialogHeight:400px;" + "dialogWidth:470px;" + "edge:sunken;" + "help:no;" + "scroll:no;" + "resizable:no;" + "status:no;" + "unadorned:no;"; showModalDialog(url, window, features); }
親画面のElementから値を取得する方法
var data = parent.dialogArguments.document.getElementById('data').innerHTML;
[変更後 (IE/mozilla)]
function showDialog() { var url = "popup.html"; if (window.showModalDialog) { var ieFeatures = "dialogHeight:400px;" + "dialogWidth:470px;" + "edge:sunken;" + "help:no;" + "scroll:no;" + "resizable:no;" + "status:no;" + "unadorned:no;"; showModalDialog(url, window, ieFeatures); } else { var windowName = "sampleDialog" var mozillaFeatures = "width=450," + "height=400," + "toolbar=no," + "location=no," + "directories=no," + "status=no," + "menubar=no," + "scrollbars=no," + "resizable=no," + "modal=yes"; window.open(url, windowName, mozillaFeatures); } return false; }
親画面のElementから値を取得する方法
var openerWindow; if (window.showModalDialog) { openerWindow = parent.dialogArguments; } else { openerWindow = parent.opener; } var data = openerWindow.document.getElementById('data').innerHTML;
[変更前]
function window_close() { window.close(); }
[変更後]
function window_close() { var nvua = navigator.userAgent; if (nvua.indexOf('MSIE') >= 0){ if(nvua.indexOf('MSIE 5.0') == -1) { top.opener = ''; } } else if (nvua.indexOf('Gecko') >= 0){ top.name = 'CLOSE_WINDOW'; wid = window.open('','CLOSE_WINDOW'); } top.close(); }