Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Mel Smith" Newsgroups: comp.lang.javascript Subject: Re: Suspending the flow of JS/ES execution Date: Fri, 13 Sep 2013 13:07:12 -0600 Lines: 173 Message-ID: References: <4fpYt.72772$wA2.68551@fx32.iad> <1ddaiqhh6qdpo.1f6innudnejww.dlg@40tude.net> X-Trace: individual.net +oNfVxWAjnNFgLq8zsHaugu2ngUb449h/JES+ZMPy/n9nefSUo Cancel-Lock: sha1:tk3UoC5D1/G7UptgOz8+SGruIhE= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: csiph.com comp.lang.javascript:21331 I wrote: > JJ said: >>> function somefunc() { >>> Alert(cmsg, alertCallback); >>> return; >>> } > > In the fragment above I would like to pass an argument to the > alertCallback() function, and in the Alert() function access thos > arguments > > In one particular instance, I need to pass a scoped variable (an > object) to the call back function. > > In a general situation, how do I pass one value (or an array of values) > to this alertCallback function. > > Thanks for an additional kick ! I gaved myself a kick. Below is my latest ES/Js for my new Alert() function: I welcome better code suggestions from all: -Mel *********** alert.js ********* var alertinit = false; // make alert box on first call only var alertinps,nalertinps,alertdisables ; function Alert(cmsg,callback,acallparm) { // have an additional parm to the Alert() call: // This acallparm is an array of 'actions' and 'objects': // parm[0] is an action : e.g., "focus", "submit", etc // parm[1] is an object for the action to 'work on' var i,alertobj,capobj,msgobj,okobj ; var inpobj,okbuttobj ; alertinps = document.getElementsByTagName("input") ; nalertinps = alertinps.length ; alertdisables = [] ; for (i=0;i

' + '
' + '
' + ' ' + '
' var containobj = getobj("container") ; containobj.appendChild(alertdiv) ; alertinit = true; // use it from now on } alertobj = getobj("ialert") ; // now set the style for the main alert box alertobj.style.position = "absolute" ; alertobj.style.top = "30%" ; alertobj.style.left = "25%" ; alertobj.style.height = "40%" ; alertobj.style.width = "50%" ; alertobj.style.marginTop = "0px" ; alertobj.style.marginBottom = "0px" ; alertobj.style.padding = "0px" ; alertobj.style.zIndex = "1000" ; alertobj.style.overflow = "auto" ; alertobj.style.textAlign = "center" ; alertobj.style.color = "black" ; alertobj.style.background = "lightgray" ; alertobj.style.border = "2px solid black" ; // now set styling for the alert caption capobj = getobj("ialertcaption") ; capobj.style.position = "absolute" ; capobj.style.top = "0%" ; capobj.style.height = "12%" ; capobj.style.marginTop = "0px" ; capobj.style.marginBottom = "0px" ; capobj.style.padding = "0px" ; capobj.style.left = "0%" ; capobj.style.width = "100%" ; capobj.style.textAlign = "center" ; capobj.style.fontWeight = "bolder" ; capobj.style.textDecoration = "underline" ; capobj.style.color = "black" ; capobj.style.background = "yellow" ; capobj.innerHTML = " Please Read Message Below, then Click 'OK' " ; // now prepare and display the message msgobj = getobj("ialertmsg") ; msgobj.style.position = "absolute" ; msgobj.style.top = "20%" ; msgobj.style.left = "0%" ; msgobj.style.width = "100%" ; msgobj.style.marginTop = "0px" ; msgobj.style.marginBottom = "0px"; msgobj.style.padding = "0px"; msgobj.style.textAlign = "center" ; // re-format with
replacing '~' chars, etc cmsg = cmsg.replace(/~/g,"
") ; msgobj.innerHTML = cmsg ; // now place the 'OK' button a bit up from the bottom of my standard Alert Box okobj = getobj("ialertok") ; okobj.style.position = "absolute" ; okobj.style.bottom = "5%" ; okobj.style.left = "45%" ; okobj.style.width = "10%" ; okobj.style.marginTop = "0px" ; okobj.style.marginBottom = "0px"; okobj.style.padding = "0px"; okobj.style.textAlign = "center" ; alertobj.style.display="block" ; okbuttobj = getobj("ialertokbutt") ; okbuttobj.onclick = function() { AlertFin(); if (callback) { // note: Check "callback" parameter here if (acallparm) callback(acallparm) ; else callback() ; } } okbuttobj.focus() ; } function AlertFin() { var i,j ; var lexit ; var nlendisables = alertdisables.length ; var alertobj = getobj("ialert") ; alertobj.style.display = "none" ; for (i=0;i 0 ) { for (j=0;j