javascript - "Unable to load http://url status:0" error in onbeforeunload-method -
may of can me find problem?
i've got xpage client-side js-code included should executed when decide leave page. in client-side js refer button , click automatically. button got server-side js code included , change flag document ("opened ..." "").
the thing somehow client-side js did not work in different browsers except current ie (10.0.5) , throws error:
unable load http://urlofthedocument/... status:0
the funny thing is, when insert alert()-method right after click()-method works fine in every browser. don't want include alert statement figure out there must different avoid this. (a short pause instead of alert-method did not work.)
my cs js-code:
window.onbeforeunload = warneditmode; function warneditmode(){ if(needunloadconfirm == true){ var el = window.document.getelementbyid("#{id:hidden4ssjs}"); el.click(); //document.open(); //document.write(el); //document.close(); //alert("you're leave page"); //pause(5000); } } function pause(millis){ var date = new date(); var curdate = null; { curdate = new date(); } while(curdate-date < millis) }
this refers to button, executes following ss js code, after clicked:
try{ print("hidden4ssjs-button-test @ person"); var db:notesdatabase = database; var agt:notesagent; var doc:notesdocument = xppersondoc.getdocument() agt = db.getagent("(xpunlockdocument)"); agt.run(doc.getnoteid()); }catch(e){ _dump(e); }
may guys can me this?
i using xsp object hidden computed field (and not special button)...
something this:
function warneditmode(){ if(needunloadconfirm == true){ xsp.partialrefreshget("#{id:unlockdoccf1}", { params: { '$$xspsubmitvalue': 'needtounlock' }, oncomplete: function () { alert('you leave page , document has been unlocked.'); }, onerror : function (e) { alert('you leave page , document has not been unlocked.\n' + e); } ); } pause(5000); }
then computed field's javascript this:
try{ var sval = @explode(context.getsubmittedvalue(), ','); if (sval == null) return result + " no action."; if (!"needtounlock".equals(sval[0])) return result + " no action."; print("hidden4ssjs-button-test @ person"); var db:notesdatabase = database; var agt:notesagent; var doc:notesdocument = xppersondoc.getdocument() agt = db.getagent("(xpunlockdocument)"); agt.run(doc.getnoteid()); return 'document unlocked.'; }catch(e){ _dump(e); }
Comments
Post a Comment