Problem on programming with Firefox with showModalDialog

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
Post Reply
aarsys
Posts: 2
Joined: November 27th, 2007, 2:17 am

Problem on programming with Firefox with showModalDialog

Post by aarsys »

I have some problems with a popup.js script that only worked in I.E. Can anybody please look at this script and tell me what is wrong here? About the function and future of using this script, I can not using the window.open command.

var SelectedColorFocused = "#adc3e7";
var SelectedColorUnfocused = "#eeeeee";
var _mode = 0;
var LookupBrowse = 0x1;
var LookupMulti = 0x4;
var LookupSingle = 0x2;

var DNN = 1;
var ADSI = 2;
var CRM = 3;
var FORUM = 4;
var GALLERY = 5;
var LIBRARY = 6;

var popUp;

function RefreshParent()
{
popUp.close();
window.location.reload();
}

function OpenGalleryPopup(targetControl, url, features)
{
var args = new PopupArguments();

if (targetControl != null)
{
var tdDisplay = targetControl.parentElement.parentElement.firstChild;
var tdValue = targetControl.parentElement;
args.items = tdDisplay.getElementsByTagName("SPAN");
}

var returnValue = window.showModalDialog(url, args, features);
if (!returnValue || returnValue.items.length == 0)
{
CleartargetControl(targetControl);
}
else
{
PopuplatetargetControl(targetControl, returnValue);
}

}


function PopupArguments()
{
this.items = null;
}

function CleartargetControl(targetControl)
{
var tdDisplay = targetControl.parentElement.parentElement.firstChild;
var idField = targetControl.parentElement.firstChild;

tdDisplay.innerHTML = "(None Specified)";
idField.value = "";
}

function PopuplatetargetControl(targetControl, resultValues)
{
var tdDisplay = targetControl.parentElement.parentElement.firstChild;
var idField = targetControl.parentElement.firstChild;
//var nameField = tdDisplay.firstChild;
var iHTML = "";
var idList = "";
//var nameList = "";
for (var i = 0; i < resultValues.items.length; ++i)
{
var item = resultValues.items[i];
if (item.name == 'popupcancel')
{
return;
}
var elem = parent.document.createElement("SPAN");
elem.className = "TTTNormalTextBox";
elem.oid = item.id;
elem.otype = item.type;
elem.olocation = item.location;
elem.innerHTML = item.html;
iHTML += elem.outerHTML;
iHTML += "<br>";
idList += ";" + item.id + ":" + item.name;
//idList += item.id + ";";
//nameList += item.name + "<br>";
}
if (iHTML.length == 0)
{
iHTML = "(None Specified)";
}
tdDisplay.innerHTML = iHTML;
idField.value = idList;
//nameField.value = nameList;

}

function checkMode(mode, option)
{
return ((mode & option) == option);
}

function openPopup()
{
return window.createPopup();
}

function search()
{
document.body.style.cursor = "wait";
var url = "popupdata.aspx";
url += window.location.search;
url += "&objectclass=" + selObject.returnValue;
url += "&location=" + selLocation.returnValue;
url += "&searchvalue=" + URLEncode(findValue.value);
btnGo.disabled = true;
findValue.focus();

frmResults.location.href = url;
}
function selectChange(o)
{
if (checkMode(_mode, LookupBrowse))
{
search();
}
}
function buildReturnValue(rows, objectclass)
{
var lookupItems = new LookupItems();
lookupItems.objectclass = objectclass;
var len = rows.length;

for (var i = 0; i <len> 0)
{
unselectItem(table, table.selectedItems[0]);
}
}
function unselectItem(table, item)
{
//alert("unselectItems2");
if (table.selectedItems == undefined) return;
var items = table.selectedItems;
for (var i = 0; i <items>= o.rowIndex)
{
var rows = table.rows;
for (var i = o.rowIndex; i < lastSelected.rowIndex; i++)
{
selectItem(table, rows[i], true);
}
}
else
{
var rows = table.rows;

for (var i = lastSelected.rowIndex + 1; i <o> 0)
{
item = item.previousSibling;

if (item.unselectable != undefined)
{
item = item.previousSibling;

if (item == null)
return;
}
unselectItems(table);

selectItem(table, item, true);



item.scrollIntoView(true);
}
}
else if (event.keyCode == 40)
{
var item = table.lastSelected;
if (item && item.rowIndex <table> 47 && event.keyCode <58> 64 && event.keyCode < 91)))
{
var code;
var len = table.rows.length;

for (i = (checkMode(_mode, LookupMulti)) ? 0 : 2; i <len> 64 && event.keyCode <91> 0)
{
selectItem(table, table.rows[0], true);
//alert("table.rows.length > 0");
}

for (var i = 0; i <items> 1)
// {
// alert("You must only select one object.");
// }
// else
// {
// }
//}

function LookupItem()
{
//alert("LookupItem");
LookupItems
this.id = "";
this.name = "";
this.location = "";
this.html = "";
this.type = "";
this.objectclass = "" ;
this.values = null;
this.keyValues = null;
}
function LookupItemData(name, value)
{

this.name = name;
this.value = value;
}
function popupCancel()
{
this.items = new Array();
var ci = new LookupItem();
ci.id = '0';
ci.name = 'popupcancel';
this.items.push (ci);
}

function LookupItems()
{

this.add = _add;
this.items = new Array();


function _add(tr, columns)
{
var li = new LookupItem();
var td = tr.cells[0];
li.id = tr.oid;
li.name = td.innerText;
li.location = tr.olocation;
li.html = td.innerHTML;
li.type = tr.otype;
li.values = new Array();
li.keyValues = new Array();

var len = columns.length;
if (len > 1)
{
for (var i = 1; i < len; ++i)
{
li.keyValues[new String(columns[i].name)] = new LookupItemData(columns[i].name, tr.cells[i].innerText)
li.values.push(new LookupItemData(columns[i].name, tr.cells[i].innerText));
}
}
this.items.push (li);
}
}

function URLEncode(s)
{
s = s.replace(" ", "%20");
s = s.replace("\"", "%22");
s = s.replace("#", "%23");
s = s.replace("&", "%26");
return s.replace("+", "%2B");
}

/*/
/ / Author: Jeremy Falcon
/ / Date: November 08, 2001
/ / Version: 1.4
/*/

/*/ THIS FILE CONTAINS FUNCTIONS THAT WILL WRAP THE POP-UP PROCESS /*/

// this variable will hold the window object
// we only allow one pop-up at a time
var popup = null;
/*/
/ / PURPOSE:
/ / To create and center a pop-up window.
/ /
/ / COMMENTS:
/ / It will replace to old pop-up if called
/ / without calling DestroyWnd() first..
/*/

function CreateWnd (file, width, height, resize)
{
var doCenter = false;

if((popup == null) || popup.closed)
{
attribs = "";

/*/ there's no popup displayed /*/

// assemble some params
if(resize) size = "yes"; else size = "no";

/*/
/ / We want to center the pop-up; however, to do this we need to know the
/ / screen size. The screen object is only available in JavaScript 1.2 and
/ / later (w/o Java and/or CGI helping), so we must check for the existance
/ / of it in the window object to determine if we can get the screen size.
/ /
/ / It is safe to assume the window object exists because it was implemented
/ / in the very first version of JavaScript (that's 1.0).
/*/
for(var item in window)
{ if(item == "screen") { doCenter = true; break; } }

if(doCenter)
{ /*/ center the window /*/

// if the screen is smaller than the window, override the resize setting
if(screen.width <= width || screen.height <= height) size = "yes";

WndTop = (screen.height - height) / 2;
WndLeft = (screen.width - width) / 2;

// collect the attributes
attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," +
"status=no,toolbar=no,directories=no,menubar=no,location=no,help=no;,top=" + WndTop + ",left=" + WndLeft;
}
else
{
/*/
/ / There is still one last thing we can do for JavaScrpt 1.1
/ / users in Netscape. Using the AWT in Java we can pull the
/ / information we need, provided it is enabled.
/*/
if(navigator.appName=="Netscape" && navigator.javaEnabled())
{ /*/ center the window /*/

var toolkit = java.awt.Toolkit.getDefaultToolkit();
var screen_size = toolkit.getScreenSize();

// if the screen is smaller than the window, override the resize setting
if(screen_size.width <= width || screen_size.height <= height) size = "yes";

WndTop = (screen_size.height - height) / 2;
WndLeft = (screen_size.width - width) / 2;

// collect the attributes
attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," +
"status=no,toolbar=no,directories=no,menubar=no,location=no,help=no,top=" + WndTop + ",left=" + WndLeft;
}
else
{ /*/ use the default window position /*/

// override the resize setting
size = "yes";

// collect the attributes
attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," +
"status=no,toolbar=no,directories=no,menubar=no,location=no,help=no";
}
}

// create the window
popup = open(file, "", attribs);
}
else
{
// destory the current window
DestroyWnd();
// recurse, just once, to display the new window
CreateWnd(file, width, height, resize);
}
}

/*/
/ / PURPOSE:
/ / To destroy the pop-up window.
/ /
/ / COMMENTS:
/ / This is available if wish to destroy
/ / the pop-up window manually.
/*/

function DestroyWnd ()
{
// close the current window
if(popup != null)
{
popup.close();
popup = null;
}
}



Thanks for your help

Matthias
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Post by trolly »

To Web Development ...
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
Unarmed
Posts: 4941
Joined: July 31st, 2003, 1:26 pm

Post by Unarmed »

<code>showModalDialog()</code> wasn’t implemented in Mozilla until just a couple months ago, so the only released browser in which it’s supported is Firefox 3 Beta 1.
aarsys
Posts: 2
Joined: November 27th, 2007, 2:17 am

Other Handling of the showModalDialog() between IE & Moz

Post by aarsys »

Unarmed wrote:<code>showModalDialog()</code> wasn’t implemented in Mozilla until just a couple months ago, so the only released browser in which it’s supported is Firefox 3 Beta 1.


But in Firefox 3 beta 1 it doesn't work too.
Are there any thing in other handling between I.E and Mozilla ?
ferdy
Posts: 17
Joined: December 1st, 2007, 5:54 am

Post by ferdy »

to use popup windows like alert in firefox you must:

function openWindow(url, title, width, height )
{
var navigatoreName = navigator.appName;

if (navigatoreName == "Netscape" )
{

netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');



window.open(url, title, 'width=' +width+ ',height=' + height+',chrome,centerscreen,dependent=YES,dialog=YES,modal=YES,resizable=NO,scrollbars=NO,location=0,status=0,menubar=0,toolbar=0');
}else
{
window.showModalDialog(url, title, "dialogHeight:" + height + "; dialogWidth:" + width +"; scroll:no");
}
}




and that opet firefox, and type in url: about:config

find parameter signed.applets.codebase_principal_support and put it in true...double click


and this is it.

note: after you open for first time popup, firefox will ask you is this ok. You click ok and remember dicisuon and you are done.

i hope i help you
Post Reply