[ZendTo] Re: "Leave This Page" warning when dropping off a file

Andrew Martin amartin at xes-inc.com
Tue Nov 25 23:22:27 GMT 2014


----- Original Message -----
> From: "Gray D. McCord" <gdm at sangabriel.com>
> To: "ZendTo Users" <zendto at zend.to>
> Sent: Tuesday, November 25, 2014 4:40:55 PM
> Subject: [ZendTo] Re: "Leave This Page" warning when dropping off a file
> 
> I ran into this quite a while back. I have two possible things you can try.
> Both involve edits to the new_dropoff.tpl file:
> SOLUTION 1:
> First, my solution, which works for me is to edit the submitform() script in
> the new_dropoff.tpl file by setting "ignore_upload = true;” in the submit
> form script and my problem went away. Now, my Zendto is highly customized
> with a JS file uploader and php5.5, so this may not work for you. Also be
> sure to make sure it doesn ’ t break something on other browsers.
> < script type= "text/javascript" >
> function submitform () {
> if ( validateForm ()) {
> document . fileupload . submit ();
> ignore_unload = true ; //TODO: Changed to true to get rid of Chrome error.
> Need to figure out why the error occurs.
> }
> }
> </ script >
> 
> 
> SOLUTION 2, from Jules, who is the Zendto owner and actually knows what he’s
> doing:
> 
> 
> From: Jules [ mailto:Jules at Zend.To ]
> Sent: 02 January 2014 11:15
> To: John Webber (NBI)
> Cc: ZendTo Users
> Subject: Re: FW: Issue with Chrome browser - "Leave this Page"
> 
> 
> 
> 
> I've got a quick fix for this. Unfortunately it means you can navigate away
> from (and hence abort) a running upload, but it stops the Chrome warning, so
> is better than nothing.
> 
> You want to edit /opt/zendto/templates/new_dropoff.tpl file:
> 
> Find the start of the "submitform" function, and add the last line of this
> little code snippet:
> 
> <script type="text/javascript">
> function submitform() {
> if (validateForm()) {
> window.onbeforeunload=function(){}
> 
> Jules.
> ————————————————————————
> Good Luck!
> Gray McCord
> Adapt, Mutate, Migrate, or Die
> -C. Darwin
> 
Gray,

Thanks for the help. It looks like both of these solutions achieve the same effect.
The first solution makes the doBeforeUnload function return immediately (rather
than doing anything):
        function doBeforeUnload() {
               if(ignore_unload) return; // Let the page unload

               if(window.event)
                      window.event.returnValue = unload_msg; // IE
               else
                      return unload_msg; // FF
        }

This function is set as the target for onbeforeunload just below where it is defined:
        if(window.body)
               window.body.onbeforeunload = doBeforeUnload; // IE
        else
               window.onbeforeunload = doBeforeUnload; // FF


The solution that Jules posted changes the function that is called for onbeforeunload
to be an empty function, rather than doBeforeUnload:
<script type="text/javascript">
function submitform() {
  if (validateForm()) {
    window.onbeforeunload=function(){}

Again thanks for the help!

Andrew



More information about the ZendTo mailing list