Any Alternate For OnBeforeUnload?

Jun 6, 2006

the bug of onbeforeunload is so obvious!

in IE 6 it will popup twice "sometimes"

I am using the following code

window.onbeforeunload = null;
window.onbeforeunload = confirmExit;
var executingPostBack = false;

function confirmExit()
{
if ( typeof executingPostBack != 'undefined' && !executingPostBack)
{
return 'Warning: Modified data has not been saved.' ;
}
}

In some cases, IE pops up it twice, for example, when we click a link
that contains "__doPostBack", onbeforeunload is fired the first time;
when the form is submitted, it is fired second time.

There is no way to work it around, because onbeforeunload is stupid, we
can't know whether the user clicks OK or Cancel.

I would like to use the following code with confirm so that I know
exactly what the user behaves

res = confirm("leaving?");
if (res==1)
{
alert("yes");
}
else
{
alert("no");
}

but I can't use this in onbeforeunload, because I can't stop it!
onbeforeunload always asks for something return, but if I return
anything, it will popup!

View 4 Replies


ADVERTISEMENT

OnBeforeUnload Alternative

Jul 23, 2005

Currently I use an onbeforeunload method, to do call various tidy up
methods when a user exits my web application - however I now need to add
additional support, for users migrating to Sun's JVM.

My understanding that the onbeforeunload call is a Microsoft one, and
the net result of having it in a page used by a SUN JVM user is that the
browser does not close.

Does anyone know of an alternative to this method, that is supported
by Sun's JVM?

View 4 Replies View Related

Onbeforeunload Issue

Jul 23, 2005

The onbeforeunload fires just before the current document begins to
unload due to form submission or window closure.

How can I have this code run after window closure (X) but not after
pressing a button (form submission)?

View 2 Replies View Related

Override Onbeforeunload

Nov 29, 2005

I want to override the onbeforeunload event so that when the user
clicks on the close button, at the right top of the screen, it only
open an alert with OK button and don't close the screen ...

View 5 Replies View Related

OnBeforeUnload And Submit() Together?

Jun 6, 2005

I have written a web application in .ASP with VBScript and JavaScript running against a SQL back end. Everything works great except my BeforeUnload() event:

<%'Add a script to save any unsaved data before the client leaves the page%>
<script language="JavaScript">
window.

function confirmExit()
{if (document.Client_Info_Page.Value_Changed.value == "true")
{if (confirm("This record has been changed. Press [OK] to save; [Cancel] to discard."))
{document.Client_Info_Page.submit();
alert("Changed and save");}
else
{alert("Changed and no save");}
}
}
</script>

<%'END Add a script to save any unsaved data before the client leaves the page%>
This code checks a variable to see if anything's been changed on the page and if it has, it asks the user if they'd like to save before exiting. The alert boxes are just to show the If/Then is working correctly (which it is) but the .Submit() function just gets ignored as the page exits.

Just to play, I made a java button and cut and pasted the submit() into and when that's clicked it submits with no problem.

Anyone know how I can get the onBeforeUnload to push a .Submit()? I've changed it to stop the exit and allow the user to save, but it would be so much smoother if it could be automatic.

View 13 Replies View Related

Can 'onbeforeunload' (ie) Be Used To Trigger A Javascript

Jul 23, 2005

Can 'onbeforeunload' (ie) be used to trigger a javascript? I can't find any info on how or if this is possible.

View 2 Replies View Related

Overriding OnBeforeUnload Dialog Message

Feb 9, 2006

Does anyone know how to suppress the default messages?

1. "Are you sure you want to navigate away from this page?"
2. "Press OK to continue, or Cancel to stay on current page"

I need to provide the user a custome message. I tried many approachs, but non of them seem to work. I tried to use a confirm box instead, but for some reason, the return value for onBeforeUnload event seem to be used as string, so return false to the event CANNOT stop the page from refreshing.

View 1 Replies View Related

Onbeforeunload Not Setting Data Values?

Jan 20, 2010

I set some value like in onbeforeUnload

document.getElementById('hGridStateModified').value='YES';
The value is not set and is not available at server side.
(

I set some value like

document.getElementById('hGridStateModified').value='YES';
The value is available at server side.
)

Code
/// START
f(window.body){
window.body.onbeforeunload = saveBeforeExit; // IE else[code].....

View 4 Replies View Related

Cancel The 'unload' Action In 'onbeforeunload' Event

Jul 23, 2005

What code can I put in the 'onbeforeunload' event to cancel the 'unload'
action (when user closes browser) and then present the user with an
alert saying that he/she must use the logout button.

View 6 Replies View Related

Avoid Confirm Message When Using Window.onbeforeunload

Sep 30, 2009

i dont want to show the confirm message when using window.onbeforeunload.Please suggest a solution to hide the confirm message..

View 3 Replies View Related

Show/Hide Divs Trigger OnBeforeUnload (IE)?

May 22, 2009

I'm trying to add the "you have unsaved changes" message to a form. I have it working in every browser except IE7 and IE8.I have set the onbeforeunload with using a global "goodExit" variable (that's supposed to help IE, and it did partially).The thing is, that I have multiple tabs on the page, so I only show part of the form at any given time. If they change a field on one tab, the top of the page shows a visual box of "unsaved data", so that as the users changes tabs the box at the top still shows.The problem is that, IE fires the onbeforeunload anytime someone clicks to change tabs. The only thing that happens when they click a tab is that I use jQuery to show/hide the DIVs appropriately.Why does IE fire onbeforeunload when changing the display of DIVs???!!!No other browser does this.The global "goodExit" variable meant to help IE, seems to work, except that goodExit is set to true if they change any field on a tab, so that then the next tab they switch to fires the event.

View 3 Replies View Related

Alternate Row Colour

Dec 9, 2005

I am generating a html based table with multiple rows of data coming
in real time from a postgres DB. The underlying technology is java
based however the front end is html.

now i am unable to alternate the colour of every row so that the table
is lot more readable. can anyone suggest a javascript or even a css
script which will alternate the row colours irrespective of the number
of rows.

View 4 Replies View Related

Alternate Submit?

Dec 12, 2006

I am making a ajax form request and I am clueless on how to make an alternate submit when javascript is disabled. This is so it works without javascript and uses a separate php file.

View 2 Replies View Related

Onclick Alternate Between 2 Values?

Dec 21, 2009

I currently have some simple JS setup but I'd like to alternate between 2 values using "onclick". I have setup a flash clip with a form input buttons for playback control. Here is my form:

PHP Code:

<form action="/" class="button">
<input type="button" name="" id="play" class="play" value="" onclick="callFlashPlayPauseVideo(1)" />
</form> 

[Code]....

However, once this intial stage has passed, and the button is clicked again - the image needs to revert back to the "play" button - so its a cause of having the pause button on show whilst the video plays, if its then clicked, the play button shows as the video is paused.

View 4 Replies View Related

Changes Another Alternate Image At The Same Time?

Mar 26, 2010

For a lot of years now I've used a javascript that does a simple rollover image swap, but also changes another alternate image at the same time. It's always worked like a charm.Lately I realized that the script no longer works in IE, though it used to in older versions of IE (I think it stopped working in anything past IE 7). It still works fine in Firefox, Safari, etc.I haven't been able to find a good alternative for this script, so I'm really trying to get it to work again in IE, but so far no luck.

Here's the link to the actual script itself. http:[ur;l]....

View 1 Replies View Related

Hidden/Alternate Menu

Jan 8, 2004

Here is a quick menu hidden in a Mouse Gesture for additional navigation on a site or administraitive duties.

To activate the menu simply right click anywhere on the screen , hold the button down, then move the mouse down 50px's and release. This will display the hidden menu.

There are two parts to it, first the Style and Script....

<style>
.expanded {
position:absolute;
padding:1px;
font:Arial, Helvetica, sans-serif;
font-size:11px;
text-align:left;
background-color:#D4D0C8;
width:150px;
border-left :2px solid #FFFFFF;
border-top :2px solid #FFFFFF;
border-right :2px solid #999999;
border-bottom : 2px solid #999999;
}
a.expanda {
padding-left:15px;
padding-right:15px;
display:block;
text-decoration:none;
color:#000000;
}
a.expanda:hover {
background-color:#003366;
color:#FFFFFF;
}
</style>
<script language="javascript">
document.oncontextmenu = null;
document.onmousedown = doDown;
document.onmouseup = doUp;
var timerID = 1;
var ly;
var ny;
var targ;
function doDown(e)
{
clearTimeout(timerID);
document.oncontextmenu = null;
var rightclick;
if (!e) e = window.event
if (e.which) rightclick = (e.which == 3);
else if (e.button) rightclick = (e.button == 2);
try
{
if (e.target) targ = e.target.getAttribute('id');
else if (e.srcElement) targ = e.srcElement.getAttribute('id');
if (targ != "navlink") {document.getElementById('altnav').style.display = 'none'}
}
catch(e)
{
document.getElementById('altnav').style.display = 'none'
}
if (rightclick != false)
{
ly = e.clientY;
}
return false;
}

function doUp(e)
{
var rightclick;
if (!e) e = window.event
if (e.which) rightclick = (e.which == 3);
else if (e.button) rightclick = (e.button == 2);
if (rightclick != false)
{
if (!e) var e = window.event;
ny=e.clientY;
lytemp = ly+50;
if (ny>lytemp)
{
document.getElementById('altnav').style.display = "block";
document.getElementById('altnav').style.left = e.clientX + 2;
document.getElementById('altnav').style.top = ly+2;
window.status = "down menu";
document.oncontextmenu = fakecontext;
timerID = setTimeout("document.getElementById('altnav').style.display = 'none'", 5000);
}
}
ly = null;
ny = null;
}
function fakecontext(){return false;};
</script>

And the menu div to place inside the body tag. Edit this to act as the menu you would like. Remember that you can access the event.target if you want to have the menu dynamicaly effect things based on whats clicked.

<div style="display:none" class="expanded" id="altnav">
<a href="http://www.news.com" class="expanda" id="navlink"><div style="float:right;width:20px;text-align:left;">Ctrl+?</div>Option 1</a>
<a href="http://www.cnn.com" class="expanda" id="navlink"><div style="float:right;width:20px;text-align:left;">Ctrl+?</div>Option 2</a>
</div>

View 9 Replies View Related

Alternate Form Fields

Apr 26, 2005

I was actually looking for a couple of alternate form field elements such as a drag bar or combo boxes. Is there something like that out there, even? (see ascii representation for example of what I mean) Code:

View 7 Replies View Related

Alternate Table Row CLASSES

May 9, 2005

There are lots of JavaScripts and PHP scripts for making tables with alternating row colors. I'd like to know if there's a way to use JavaScript to give a table alternate row CLASSES.

My ultimate goal is to cut down on the html and gain more control over my table. I have a PHP script that gives me alternate cell colors, with different colors in each of two table columns. But it's just too complex to work with. Code:

View 3 Replies View Related

Alternate Cell Content Wi JS

Feb 5, 2010

I am building a display which is made up of a XHTML table, CSS styling and JS animation.

The effect I am looking for is for the (mutliple) cell's content to alternate between one word to another.

My initial idea was to build an array to count through the cell numbers like I have for another section of the board in this snippet..

var flsh = document.getElementsByTagName('td');
for (var i=0;i<flsh.length;i++); //flash alert cells
{
cell = !cell;

[Code]....

This code flashes some of the other cells each second, however for my alternating text I'm not sure what methods to use since .style.backroundColor wont suit this.

View 3 Replies View Related

Alternate Way To Store/get XML Data ?

Mar 21, 2011

I have a project that I need to read some data from an XML file.

Something like:

However, since JS is a client side script so it can't read from client side, is there any alternate way to do this? I am thinking to create a "Data" class, and many "Data" objects, is this an elegant way to do it?

View 5 Replies View Related

Alternate Textareas To Be Visible?

Apr 23, 2011

Basically i have a function that depending on which picture you click (one for "yes" and other for "no") it will make visible a textarea .

However right now if i click in "yes" it will display me the textarea for yes, and afterwards if i click "no" it will display both textareas, for yes and no. I want everytime i click on yes it will hide the "no" textarea and the same for when i click the "no" textarea, it will hide the "yes" textarea.

Code:
<!- * * * * * * * * * * * * O.S. Question * * * * * * * * * * * * * * * -->
Original Operating System ?</strong></span><div id="container">
<div id="left">
<img src="yes.png" onclick="document.getElementById('moreinfo22').style.display =

[Code].....

View 4 Replies View Related

JQuery :: How To Color Alternate Words

Aug 26, 2011

I am a little new to java script and jQuery so, if you can, please ignore my ignorance. I am creating a theme for Joomla and am calling in the website title using php. I would like so that every other word is a different color.

[Code]...

I would like to use jQuery to make every other word a different color in that specific span.

View 1 Replies View Related

JS Redirection Shows Alternate Text

Jan 27, 2011

I have a javascript redirection with an alternate text for those who have javascript disabled.

It all works fine but before redirection the alternate text displays shortly. Can I prevent that?

Code:

I also tried to hide the text with an onload event, but nothing changes

View 3 Replies View Related

Alternate DIV Rows But In Specific Section?

Mar 13, 2011

Is there away to alternate DIV rows in a specific section. When I try to alternate the DIVs it alternates everything that is a DIV on the page. I want to just alternate a DIV table.

View 4 Replies View Related

Styling Alternate Rows Of A Table?

Oct 20, 2009

Code:

function stripeTables() {
if(!document.getElementsByTagName) return false;
var tables = document.getElementsByTagName("table");
for(var i=0;i<tables.length; i++) {

[code]....

how does the script know if odd is true or false? The script works, but I'm missing this one concept. Is "odd" a JS keyword or something?

View 4 Replies View Related

JQuery :: Loop Alternate Elements?

Jul 8, 2010

how to loop alternate elements in JQuery starting from an given index. all the elements have same CLASS values.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved