• clicking on list item in List Text Box or Name Text Box trigger onbeforeunload in IE

    By Richard G Irwin 1 decade ago

     

    Hi there,

     

    Anyone know of a workaround for when using the Dojo List Text Box or Dojo Name Text Box in IE with a onbeforeunload function? As both these controls are rendered as anchor tags with href attributes (i.e. 'links"), IE, in all its wisdom, assumes that the user has initiated a navigation away from the page, which triggers onbeforeunload. If the list items were rendered as something else, perhaps a button or even just plain text, this could be avoided.

    To reproduce this effect, open the XpagesExt.nsf demo database to the Extended Form Controls page in IE, then using the developer tools, type something like this into the script console:

    window.onbeforeunload = function(e){return "this is a navigation warning string";}

    After doing so, clicking on any of the list items to delete it will bring up the 'leaving page' dialog.

     

    Anyone have any idea how to stop this?

    Rich

    • found a solution,need to modify extlib source

      By Richard G Irwin 1 decade ago

      I found that most of the anchor tags generated by xpages used "#" as the href value so tried to modify the ones created by the control and could not get my code to run at a time that worked... I could fix it onClientLoad, but if the list was modified, they got rewritten, and my onChange handler seemed to run before the list items were rewritten. onFocus and onClick were both too late.

       

      So enough of trying to fix it on the fly, I went back to the source that created the list (ListTextBox.js) and found where it creates the href="javascript:;". By replacing that with href="#" my issues were resolved. Listed here is my diff for the file extlib/dijit/ListTextBox.js in com.ibm.xsp.extlib.controls:

      63c63

       

      <  href: 'javascript:;',
      
      ---
      
      >  href: '#',
      
       
      

      Should I create this as a "defect" to get this fix into the distributed version?

       

      Rich