egoselfaxis
asked on
Need to add confirm (Yes or No) prompt to javascript function
I need to update the following javascript function with a confirm dialog (ie: Yes or No prompt):
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------
// BetterInnerHTML v1.15 - by Craig Buckler, http://www.optimalworks.net/
function BetterInnerHTML(_1,_2,_3){ function Load(_4){var _5;if(typeof DOMParser!="undefined"){_5 =(new DOMParser()).parseFromStri ng(_4,"app lication/x ml");}else {var _6=["MSXML2.DOMDocument"," MSXML.DOMD ocument"," Microsoft. XMLDOM"];f or(var i=0;i<_6.length&&!_5;i++){ try{_5=new ActiveXObject(_6[i]);_5.lo adXML(_4); }catch(e){ }}}return _5;}function Copy(_8,_9,_a){if(typeof _a=="undefined"){_a=1;}if( _a>1){if(_ 9.nodeType ==1){var _b=document.createElement( _9.nodeNam e);for(var a=0,attr=_9.attributes.len gth;a<attr ;a++){var _d=_9.attributes[a].name,a Value=_9.a ttributes[ a].value,e vt=(_d.sub str(0,2)== "on");if(! evt){switc h(_d){case "class":_b.className=aValu e;break;ca se "for":_b.htmlFor=aValue;br eak;defaul t:_b.setAt tribute(_d ,aValue);} }}_8=_8.ap pendChild( _b);if(evt ){_8[_d]=f unction(){ eval(aValu e);};}}els e{if(_9.no deType==3) {var _e=(_9.nodeValue?_9.nodeVa lue:"");va r _f=_e.replace(/^\s*|\s*$/g ,"");if(_f .length<7| |(_f.index Of("<!--") !=0&&_f.in dexOf("--> ")!=(_f.le ngth-3))){ _8.appendC hild(docum ent.create TextNode(_ e));}}}}fo r(var i=0,j=_9.childNodes.length ;i<j;i++){ Copy(_8,_9 .childNode s[i],_a+1) ;}}_2="<ro ot>"+_2+"< /root>";va r _11=Load(_2);if(_1&&_11){i f(_3!=fals e){while(_ 1.lastChil d){_1.remo veChild(_1 .lastChild );}}Copy(_ 1,_11.docu mentElemen t);}}
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------
How would I do that? Also, ... how would I update the link that triggers the function? :
<a href='javascript:BetterInn erHTML(doc ument.getE lementById ("narrativ e"),"Text to be inserted");'>Insert</a>
Please advise.
Thanks,
- Yvan
--------------------------
// BetterInnerHTML v1.15 - by Craig Buckler, http://www.optimalworks.net/
function BetterInnerHTML(_1,_2,_3){
--------------------------
How would I do that? Also, ... how would I update the link that triggers the function? :
<a href='javascript:BetterInn
Please advise.
Thanks,
- Yvan
I would start my first uncompacting javascript so i could see it clearly...all the line spaces have been removed...but the code is still the same.
ASKER
Sorry - the library is not available in an uncompressed format.
http://www.optimalworks.net/resources/betterinnerhtml/
http://www.optimalworks.net/resources/betterinnerhtml/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah .. there we go. That worked great.
Thanks so much!
- Yvan
Thanks so much!
- Yvan