Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Have a custom popup Alert mimic a windows alerts

Posted on 2003-12-09
21
Medium Priority
?
526 Views
Last Modified: 2008-03-10
I have custom alert popup made with a div.  There are certain points within my code such as when the user will get logged off of the server after a certain amount of time.  When this happens an Alert popups to inform the user that the session has expired and then once you click ok will bring you back to the login screen.  With the current code using the div it pops up and then proceeds to do then re-directing code.

I know you can't halt the code.  No points for stating the obvious.  I need a work-around method.  I've been trying some ideas using setTimeout to recheck whether or not the div is still visible to no avail.  Any help would be great, thanks!
0
Comment
Question by:dgelinas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
  • 5
  • +1
21 Comments
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9906111
so you want to check if the div is hiiden or visible?

is this correct?
0
 
LVL 6

Author Comment

by:dgelinas
ID: 9906170
Yes I'm going to be checking if it is visible or hidden.  

But I need the code to loop checking for whether or not it is hidden and once it is then have it continue from there.  
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9906317
I would do the following:

Any time the div visibility is toggle to visible, set a global variable, bolVisible, to true. When it is toggled to invisible, set the variable to false. Then you only need check the value of the variable.

FtB
0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 1800 total points
ID: 9906389
The other possibility is to use the onLoad() method of the page where the redirect takes place to spawn a new pop up.

That way, you don't have to worry about whether it is visible, closed, and etc.

Fritz the Blank
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9906659
i may be lost but can you not do this

if(document.getElementById('alertDIV').style.visibility == 'visible'){
     // Do What you want because it is visible
}
else {
       // Do what you need to since its hidden
}
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9906696
If your browser is recent enough, and the window isn't closed, then that should do it as well.

FtB
0
 
LVL 6

Author Comment

by:dgelinas
ID: 9906844
heh must be lost.. I'm looking to something like this

  function WaitForClose () {                  
    if ( alertBox.visibility=="visible" )    
      setTimeout ( WaitForClose, 500 );
        else
          alertVisible = false;             
  }

0
 
LVL 6

Author Comment

by:dgelinas
ID: 9906863
Fritz I can narrow it down and modify code in each situation(too much code), but I'd rather be able to just have it loop like I posted above. thanks for trying though
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9906874
alertBox.style.visibility=="visible"

FtB
0
 
LVL 6

Author Comment

by:dgelinas
ID: 9906876
whoops, here it is rather, forgot the style.  Anyone see why this wouldn't halt?

 function WaitForClose () {                  
    if ( alertBox.style.visibility=="visible" )    
      setTimeout ( WaitForClose, 500 );
        else
          alertVisible = false;            
  }
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9906883
Also, I may be mistaken, but you might have to put your function name in delimiters:

setTimeout ( 'WaitForClose()', 500 );
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9906893
So, putting it together:

 function WaitForClose () {                  
    if ( alertBox.style.visibility=="visible" )    
      setTimeout ( "WaitForClose", 500 );
        else
          alertVisible = false;            
  }
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9906898
function WaitForClose () {                  
    if (document.getElementById('alertBox').visibility=="visible" )    
      setTimeout ("WaitForClose()", 500 );
        else
          document.getElementById('alertBox').visibility= "hidden"            
  }
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9906906
Hah! Beat you by 2 milliseconds!

FtB
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9906916
you need to give your alert div a id and name it "alertBox"

<div id="alertBox">
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9906924
took me 2ms to type document.getElementById
0
 
LVL 6

Author Comment

by:dgelinas
ID: 9907165
Thanks but the reason why the code I pasted wasn't perfect is because I didn't paste it from what I was using, I typed it out because that is generally the basic idea of what I'm trying to do..

The code the way it is gives memory errors, because it puts itself in an infinite loop.  There is a button found on the Div that once clicked will make it hidden, which will then effect the condition.  Problem is that as soon as this code is run it gives me memory errors.
 
Even though I have it run itself after a specified time and check a condition it doesn't seem to be working that way I have set it to work.  
 

0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9907207
can you show us a link or posted the ORIGINAL code

basically all we are doing is playing a guessing game, with one script to try and make another work.

If you will post the code your having problems with, we may be able to help you get rid of the meomry leak/problem
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9907231
The basic premise is fine:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
var intCounter = 0

function showCounter(){
       if(intCounter<5){
            intCounter++;
            alert(intCounter);
            setTimeout("showCounter()",3000);
      }
}
//-->
</SCRIPT>

</HEAD>
<BODY onLoad=showCounter()>

<P>&nbsp;</P>

</BODY>
</HTML>

FtB
0
 
LVL 4

Expert Comment

by:Oliver_Dornauf
ID: 9912326
For me it seems you should solve the problem on your server not on the client side
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9912869
Again, I would spawn the popup with the onLoad of the window from the redirect. That way, you have tighter control.

FtB
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question