AttributionsTogether: 1 IDependOn-Set: 1 IDependOn-Set: 102 IDependOn-Set: 110 IDependOn-Set: 111 IDependOn-Set: 112 IDependOn-Set: 98 LastModifiedSecs: 1006808797 Parent: 110 SequenceNumber: 13 Title: confirm_flexible.js Part: 0 Author-Set: sauer@cloudmaster.com LastModifiedSecs: 1006808710 Type: Lines: 1 The newer, more flexible version. I didn't finish the local:// URL support, but that should be pretty trivial. I just didn't need it. Someday... EndPart: 0 Part: 1 Author-Set: sauer@cloudmaster.com LastModifiedSecs: 1006808765 Type: html Lines: 2 demo - http://www.cloudmaster.com/~sauer/demos/confirm_flexible.html
source - http://www.cloudmaster.com/~sauer/demos/confirm_flexible.js EndPart: 1 Part: 2 Author-Set: sauer@cloudmaster.com LastModifiedSecs: 1006808797 Type: monospaced Lines: 151 // JavaScript functions to replace "confirm" with an arbitrary // web page // // usage: promptem("message") // display message box with the preformatted message included. // promptem("http://site.com/page.htm") // display message box with the remote URL included // promptem("local://path/to/page.htm") // display message box with the relative URL included // // promptem("arg1", "height", "width") // specify a height and width after the first argument optionally // you can change these defaults var title = "Confirmation"; var h = 200; // default height var w = 250; // default width // you can change the "false"s to "true"s and vice-versa if need be. function setParams(){ var p = ""; p += "toolbar=false"; p += ",location=false"; p += ",directories=false"; p += ",status=false"; p += ",menubar=false"; p += ",scrollbars=false"; p += ",resizable=false"; p += ",copyhistory=false"; return(p); } /******************************************************************************/ // don't screw with stuff after this line /******************************************************************************/ var returned = false; var retVal = false; var out; var i=0; function promptem(){ window.name = "lenny"; var text = arguments[0]; var params = setParams(); if(arguments.length > 1){ h = arguments[1]; w = arguments[2]; } params += ",height=" + h + ",width=" + w; out = window.open('', 'out', params); out.document.close(); writeWindow(out); writeContent(text, out.frames['content']); writeConfirm(out.frames['bottom']); out.focus(); returned = false; while(! returned){ setTimeout(waitForClick, 50); } alert(i); waitForClick(); return(retVal); } // bah. function waitForClick(){ i++; // alert(i); // if(! returned){ // setTimeout(waitForClick, 50); // } } // generates the frameset function writeWindow(win){ win.document.open(); win.document.writeln("" + title + ""); with(win.document){ write(""); writeln(""); writeln(""); writeln(""); close(); } } // puts the content into the content frame function writeContent(text, win){ colonAt = text.indexOf("://"); spaceAt = text.indexOf(" "); url = false; if(colonAt != -1 && (spaceAt == -1 || spaceAt > colonAt)){ url = true; } if(url){ win.location.assign(text); }else{ with(win.document){ close(); open(); writeln(""); writeln(substitute(text,"\n","
\n")); writeln(""); close(); } } } // puts the buttons into the bottom frame function writeConfirm(win){ with(win.document){ close(); open(); writeln("

"); writeln(""); writeln(""); writeln("

"); close(); } } // OK button click handler function butt1(){ retVal = true; returned = true; out.window.close(); } // Cancel button click handler function butt2(){ retVal = false; returned = true; out.window.close(); } // replaces all instances of needle in haystack with newNeedle function substitute(haystack, needle, newNeedle){ var end = 0; var start = haystack.indexOf(needle, end); while(start != -1){ end = start + needle.length; newHaystack = haystack.substring(0, start); newHaystack += newNeedle; newHaystack += haystack.substring(end, haystack.length); end = start + newNeedle.length; haystack = newHaystack; start = haystack.indexOf(needle, end); } return haystack; } EndPart: 2