View Full Version : Ending a function on submit!

06-30-2008, 11:27 PM
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.


rnd me
07-01-2008, 09:22 AM
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.

07-01-2008, 05:31 PM
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

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.width= pageWidth;
dark.style.height= pageHeight;
} else {


also i have tried using a nap(); or sleep(); but it didnt work!!!

07-02-2008, 06:36 AM
How about an onunload() function to revert the page to some stable state?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum