showModalDialog and mozilla

matross

Новичок
showModalDialog and mozilla

В мозиле не работает єта функция, как ее мона заменить... Результат должен быть таким: при загрузке всплывает окно, на котором наведен фокус, при чем он должен быть только на нем(при клике на парент окно фокус должен оставаться на этом попап окне)....
 

matross

Новичок
Автор оригинала: Vital_N
в window.open указывай dependent
Теперь в експлоре проблемы, мозила работает, а експлора нет
Фокус есть в мозиле, а експлора убирает его и показывает парент виндоу
 

Vital_N

Новичок
matross
дык ты ж сказал тебе для мозилы ))
dependent не работает в ие
есть кроссбраузерное решение
 

Vital_N

Новичок
Главное окно
-------------------------------------------------------------------
<html>
<head>
<title>Main Application Page</title>
<script type="text/javascript" src="simModal.js"></script>
<script language="JavaScript" type="text/javascript">
// function to run upon closing the dialog with "OK".
function setPrefs( ) {
// Statements here to apply choices from the dialog window
}
</script>
</head>
<body onclick="checkModal( )" onfocus="return checkModal( )">
<!-- Page Content Here -->
<a href="noPrefs.html" onmouseover="status='Set preferences...';return true"
onmouseout="status='';return true"
onclick="openSimDialog('dialog_main.html', 400, 300, setPrefs);return false">
Preferences
</a>
<!-- More Page Content Here -->
</body>
</html>
---------------------------------------------------------------
дочернее окно
---------------------------------------------------------
<html>
<head>
<title>Preferences</title>
<script language="JavaScript" type="text/javascript">
// close the dialog
function closeme( ) {
window.close( );
}

// handle click of OK button
function handleOK( ) {
if (opener && !opener.closed && opener.dialogWin) {
opener.dialogWin.returnFunc( );
} else {
alert("You have closed the main window.\n\nNo action will be taken on the " +
"choices in this dialog box.");
}
closeme( );
return false;
}

// handle click of Cancel button
function handleCancel( ) {
closeme( );
return false;
}
</script>
</head>
<body onload="if (opener && opener.blockEvents) opener.blockEvents( )" onunload="if
(opener && opener.unblockEvents) opener.unblockEvents( )">
<!--- Dialog Window Page Content Here -->
<form>
<input type="button" value="Cancel" onclick="handleCancel( )">
<input type="button" value=" OK " onclick="handleOK( )">
</form>

</body>
</html>
--------------------------------
simModal.js
------------------------------------
// Global flag for Navigator 4-only event handling branches.
var Nav4 = ((navigator.appName = = "Netscape") && (parseInt(navigator.appVersion) = = 4))

// One object tracks the current modal dialog opened from this window.
var dialogWin = new Object( );

// Event handler to inhibit Navigator 4 form element
// and IE link activity when dialog window is active.
function deadend( ) {
if (dialogWin.win && !dialogWin.win.closed) {
dialogWin.win.focus( );
return false;
}
}

// Since links in some browsers cannot be truly disabled, preserve
// link onclick & onmouseout event handlers while they're "disabled."
// Restore when re-enabling the main window.
var linkClicks;

// Disable form elements and links in all frames.
function disableForms( ) {
linkClicks = new Array( );
for (var i = 0; i < document.forms.length; i++) {
for (var j = 0; j < document.forms.elements.length; j++) {
document.forms.elements[j].disabled = true;
}
}
for (i = 0; i < document.links.length; i++) {
linkClicks = {click:document.links.onclick, up:null};
linkClicks.up = document.links.onmouseup;
document.links.onclick = deadend;
document.links.onmouseup = deadend;
document.links.disabled = true;
}
window.onfocus = checkModal;
document.onclick = checkModal;
}

// Restore form elements and links to normal behavior.
function enableForms( ) {
for (var i = 0; i < document.forms.length; i++) {
for (var j = 0; j < document.forms.elements.length; j++) {
document.forms.elements[j].disabled = false;
}
}
for (i = 0; i < document.links.length; i++) {
document.links.onclick = linkClicks.click;
document.links.onmouseup = linkClicks.up;
document.links.disabled = false;
}
}

// Grab all Navigator events that might get through to form
// elements while dialog is open. For IE, disable form elements.
function blockEvents( ) {
if (Nav4) {
window.captureEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS);
window.onclick = deadend;
} else {
disableForms( );
}
window.onfocus = checkModal;
}

// As dialog closes, restore the main window's original
// event mechanisms.
function unblockEvents( ) {
if (Nav4) {
window.releaseEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS);
window.onclick = null;
window.onfocus = null;
} else {
enableForms( );
}
}

// Generate a modal dialog.
// Parameters:
// url -- URL of the page/frameset to be loaded into dialog
// width -- pixel width of the dialog window
// height -- pixel height of the dialog window
// returnFunc -- reference to the function (on this page)
// that is to act on the data returned from the dialog
// args -- [optional] any data you need to pass to the dialog
function openSimDialog(url, width, height, returnFunc, args) {
if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) {
// Initialize properties of the modal dialog object.
dialogWin.url = url;
dialogWin.width = width;
dialogWin.height = height;
dialogWin.returnFunc = returnFunc;
dialogWin.args = args;
dialogWin.returnedValue = "";
// Keep name unique.
dialogWin.name = (new Date( )).getSeconds( ).toString( );
// Assemble window attributes and try to center the dialog.
if (window.screenX) { // Navigator 4+
// Center on the main window.
dialogWin.left = window.screenX +
((window.outerWidth - dialogWin.width) / 2);
dialogWin.top = window.screenY +
((window.outerHeight - dialogWin.height) / 2);
var attr = "screenX=" + dialogWin.left +
",screenY=" + dialogWin.top + ",resizable=no,width=" +
dialogWin.width + ",height=" + dialogWin.height;
} else if (window.screenLeft) { // IE 5+/Windows
// Center (more or less) on the IE main window.
// Start by estimating window size,
// taking IE6+ CSS compatibility mode into account
var CSSCompat = (document.compatMode && document.compatMode != "BackCompat");
window.outerWidth = (CSSCompat) ? document.body.parentElement.clientWidth :
document.body.clientWidth;
window.outerHeight = (CSSCompat) ? document.body.parentElement.clientHeight :
document.body.clientHeight;
window.outerHeight -= 80;
dialogWin.left = parseInt(window.screenLeft+
((window.outerWidth - dialogWin.width) / 2));
dialogWin.top = parseInt(window.screenTop +
((window.outerHeight - dialogWin.height) / 2));
var attr = "left=" + dialogWin.left +
",top=" + dialogWin.top + ",resizable=no,width=" +
dialogWin.width + ",height=" + dialogWin.height;
} else { // all the rest
// The best we can do is center in screen.
dialogWin.left = (screen.width - dialogWin.width) / 2;
dialogWin.top = (screen.height - dialogWin.height) / 2;
var attr = "left=" + dialogWin.left + ",top=" +
dialogWin.top + ",resizable=no,width=" + dialogWin.width +
",height=" + dialogWin.height;
}
// Generate the dialog and make sure it has focus.
dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr);
dialogWin.win.focus( );
} else {
dialogWin.win.focus( );
}
}

// Invoked by onfocus event handler of EVERY frame,
// return focus to dialog window if it's open.
function checkModal( ) {
setTimeout("finishChecking( )", 50);
return true;
}

function finishChecking( ) {
if (dialogWin.win && !dialogWin.win.closed) {
dialogWin.win.focus( );
}
}

-~{}~ 04.05.05 15:32:

подработаешь под себя - просто главная фишка Modal - оно возвращает значение - если тебе этого не надо просто используй checkModal
 

akd

dive now, work later
Команда форума
что-то изменилось в ситуации с cross-browser модальными окнами или тоже подтачивать это под себя?
 
Сверху