Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,179
    Thanks
    174
    Thanked 257 Times in 257 Posts

    Ending a function on submit!

    I have a small problem where i have a blck screen show up when a PDF is generated. The problem is, if the user clicks the back button on the browser, it stays black.

    What i need is for the function to die once it changes pages. Let me know if you know of any way to do this.

    Thanks!

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    many browsers freeze the page as it was when left, and revert everything back to the way it was when you left.

    i know that in firefox3, it doesn't re-run scripts, so there isn't really a way to do this.


    i would schedule something to revert the page's appearance immediately before changing the window's location. the last line in the function before return...

    if you can post the code, i can show you how to roll-it-back if you get stuck.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • #3
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,179
    Thanks
    174
    Thanked 257 Times in 257 Posts
    ok, i have added some things to the JS so u can understand what each part is doing. I have now realized that when the user(or if) clicks the back button it only shows up black in Safari (mac)
    So may not be too important! Thanks for any help


    Code:
    function grayOut(vis, options) {
      // Pass true to gray out screen, false to ungray
      // options are optional.  This is a JSON object with the following (optional) properties
      // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
      // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
      // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
      // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
      // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
      // in any order.  Pass only the properties you need to set.
      var options = options || {}; 
      var zindex = options.zindex || 50;
      var opacity = options.opacity || 70;
      var opaque = (opacity / 100);
      var bgcolor = options.bgcolor || '#000000';
      var dark=document.getElementById('darkenScreenObject');
      if (!dark) {
        // The dark layer doesn't exist, it's never been created.  So we'll
        // create it here and apply some basic styles.
        // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
        var tbody = document.getElementsByTagName("body")[0];
        var tnode = document.createElement('div');           // Create the layer.
            tnode.style.position='absolute';                 // Position absolutely
            tnode.style.top='0px';                           // In the top
            tnode.style.left='0px';                          // Left corner of the page
            tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
            tnode.style.display='none';                      // Start out Hidden
            tnode.id='darkenScreenObject';                   // Name it so we can find it later
        tbody.appendChild(tnode);                            // Add it to the web page
        dark=document.getElementById('darkenScreenObject');  // Get the object.
      }
      if (vis) {
        // Calculate the page width and height 
        if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
            var pageWidth = document.body.scrollWidth+'px';
            var pageHeight = document.body.scrollHeight+'px';
        } else if( document.body.offsetWidth ) {
          var pageWidth = document.body.offsetWidth+'px';
          var pageHeight = document.body.offsetHeight+'px';
        } else {
           var pageWidth='100%';
           var pageHeight='100%';
        }   
        //set the shader to cover the entire page and make it visible.
        dark.style.opacity=opaque;                      
        dark.style.MozOpacity=opaque;                   
        dark.style.filter='alpha(opacity='+opacity+')'; 
        dark.style.zIndex=zindex;        
        dark.style.backgroundColor=bgcolor;  
        dark.style.width= pageWidth;
        dark.style.height= pageHeight;
        dark.style.display='block';                          
      } else {
         dark.style.display='none';
    	 
      }
    }
    also i have tried using a nap(); or sleep(); but it didnt work!!!

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    How about an onunload() function to revert the page to some stable state?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •