Avatar of Gareth_Pointon
Gareth_Pointon

asked on 

Call Function ASP

Hi,

I have a popup window on my internal intranet system that what the session times out is loading the login page.

I would like to user security script to fire a function to close the popup and redirect the user on the main browser window.

If the popup is not open then there is no problem as the User security check script redirects on the main windows anyhow.

Thanks
ASPJavaScriptVB Script

Avatar of undefined
Last Comment
Gareth_Pointon
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

This is a little hard to follow.  Do you have serverside vb script or client side js script that checks to see if you are logged in?  If not, then it fires a pop up? probably through javascript?

Somehow in your wording it is not completely clear?

Thank you.
Avatar of Gareth_Pointon
Gareth_Pointon

ASKER

Hi,

No its a server side script that is just a ASP if Statement. This is not a Java or VB script.

What I would like is for the ASP if Statement to fire a function that will close the POPUP window that is possibly in use or open in the background.

This popup window is a job overview and update window. Please are not closing it do I would like the session time out If statement to fire the POPUP window close function.
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

If you have a pop up, chances are it is javascript/jquery or at least that is what you would use to close it.  Remember, your asp and vb code runs on the server before the page even loads.  Once the page loads, you have lost all access to the server.  

If you are running some kind of ajax function to see if the session is alive, then you are using javascript or jquery.  

To answer your question, the only way to close a pop up is sending either a get or post back to the server.   You would probably want to do this with javascript or jquery and not hit the server.

What is the code you are using to make the pop up?
Avatar of Gareth_Pointon

ASKER

The POPUP has a window name so can we not just call that window to close?
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

You can't do that.

Once the ASP page has completed and rendered the HTML to the browser it ceases to exist. The only way ASP can become active again is if a post or get is sent to the server.

You can't use ASP to interact with the browser. ASP can render the javascript that will interact with the browser but cannot interact directly.
Avatar of Gareth_Pointon

ASKER

I know.

Thats why I want the <%If CALLJAVASCRIPT %> statement to call the Javascript to close the window.

I'm not asking the ASP script to close it. I'm asking the Javascript to close it but to be called with in an ASP IF statement.
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Ok you are confusing us - you said

No its a server side script that is just a ASP if Statement. This is not a Java or VB script.

Thats why I want the <%If CALLJAVASCRIPT %> statement to call the Javascript to close the window.

How exactly do you envisage this working?

ASP can output the javascript to do the work - but that does not activate until after the ASP script terminates.

What you are suggesting (if I understand you correctly) can't be done - you can't call the javascript function from ASP.
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Please render your page with the pop up, view source, then copy and paste the code. Or provide us with a sample link.

ASP or VB is not in the solution here.  It is just a matter of a javascript or jquery function needed to listen for something, and based on some criteria, close the pop up.

I understand the confusion but asp/vb work differently than js.
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

If I understand this correctly you are going to be trying to use javascript on the main page to close a popup when the main page is closed.  There is no reliable way to insure that such an action would always take place.  

Cd&
Avatar of Gareth_Pointon

ASKER

OK Guys .. Sorry about the confusion.

At present I have :

<%
If (Session("ETuserGood") = False or IsNull(Session("ETuserGood")) = True) and Request.ServerVariables("PATH_INFO") <> "/login.asp" then
URL=Request.ServerVariables("server_name")
	Response.Redirect "http://"&URL&"/login.asp"
End If

If (Request.ServerVariables("PATH_INFO") = "/login.asp" and Session("ETuserGood") = True) Then
URL=Request.ServerVariables("server_name")
	Response.Redirect "http://"&URL&"/index.asp"
End If
%>

Open in new window


The issue is that if the user has the details page open (POPUP window) then they get redirected in the popup window to the login page and not on the main window.

This is confusing the users as they then have a load of windows open.

I would like the POPUP window to be closed and then the main.window to be reloaded. This will then take them back to the login page correctly.

I hope thats clear now.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Gareth_Pointon

ASKER

I agree the modals would be good but I'm again finding people are clicking out side the box and loosing work as this is then closing the modals down.

I cannot get the script to be fired in the ASP using the suggested  response.write "<script> close_login_window()</script>"
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

>I cannot get the script to be fired in the ASP
That is because I don't believe you can have page 1 close page 2.   The code I gave you only works on the same page.  I probably shouldn't have posted it as a solution.  But it does help show what you can and can't do.  

Why does the log in need a pop up though?  I'm confused on that part.  Does the pop up have some type of timer?  if that is the case, the pop up can use ajax to test for the session.  If not logged in, then self close.
Avatar of Gareth_Pointon

ASKER

Hi,

The login is not in a popup. When you log in its on the main windows and you can navigate through the site as normal.

The issue comes when they load the job overview window that is a popup. This is where they can amend the jobs and so on. They then should close that window down but are not doing.

If they leave that window open and leave the system for some time then the session times out.  When they then go back to that page it then takes them to the login window and their then using the system in the small popup window.

I know its user training but when people just dont do something there is nothing you can then do.

Maybe what I should do is get the system to load the login in a model and then reload the original page....
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Keep in mind you are making statements that you fully understand and I don't.

>The issue comes when they load the job overview window that is a popup

That pop up can do an ajax call to check if logged in or have a js timer.  If either logged out or timer runs out, close it's self independent of the other windows.
Avatar of Gareth_Pointon

ASKER

mmm .. a JS timer sounds good ...

Can that also warn the user they are about to be logged out?

If so is there anywhere that has a sample script please.

thanks
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

One of the problems as you know the session can time out for other reasons besides time so you are making an estimate.  If  you have your server session set for 15 minutes, I would set the js timer for a little less.  

I use this timer countdown http://keith-wood.name/countdown.html.  
They show this sample to display text after the countdown reaches zero
$('#expireMessage').countdown({until: shortly, 
    expiryText: '<div class="over">It\'s all over</div>'}); 
     
$('#expireMessageStart').click(function() { 
    shortly = new Date(); 
    shortly.setSeconds(shortly.getSeconds() + 5.5); 
    $('#expireMessage').countdown('option', {until: shortly}); 
});

Open in new window

Instead of displaying text, just call a js or jquery function to close the self window.

I have something similar where I do an ajax call to a blank asp page that just tests if the session is still alive.   If it is not, I send a modal to log back in.
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Why not just put a meta-refresh tag in the header of the popup - assuming it is in a separate window - and have that redirect the page when it times out?
Avatar of G_H
G_H
Flag of United Kingdom of Great Britain and Northern Ireland image

One of the problems as you know the session can time out for other reasons besides time so you are making an estimate.  If  you have your server session set for 15 minutes, I would set the js timer for a little less.

If the popup does an Ajax call to the server every 5 minutes, then this would probably keep the session alive..?

That excepted, would it not be possible (excuse the quasi-code) to send this to the popup if the session had timed out:

<script>
window.parent.AjaxfunctionToReloadPageWithTheLoginPage;
window.self.close
</script>

Open in new window


This is similar to what I do when my uploadify popup has finished it's queue...

GH
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

then this would probably keep the session alive..?
I does.  It is really the idle time out on the app pool that people forget about that is the cause of premature time outs.  The ajax call would prevent that from happening. If you set the idle time out to 7 minutes and the ajax call is every 5 minutes, it will take  a long time to time out.
Avatar of Gareth_Pointon

ASKER

Sorry been on holiday. Going to try this week...
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo