using events / miserver
10 posts
• Page 1 of 1
using events / miserver
Hi,
How could I call a APL function when closing a browser? (for instance: pageAA.dyalog?action=closebrowser)? Where should I read/see examples about using events in miserver?
Thanks,
Marco
How could I call a APL function when closing a browser? (for instance: pageAA.dyalog?action=closebrowser)? Where should I read/see examples about using events in miserver?
Thanks,
Marco
- Gantois
- Posts: 90
- Joined: Thu Apr 17, 2014 9:44 am
Re: using events / miserver
http://miserver.dyalog.com/ > References / "Event Handling" should help for the first steps...
-
MBaas - Posts: 156
- Joined: Thu Oct 16, 2008 1:17 am
- Location: Gründau / Germany
Re: using events / miserver
Thanks MBaas,
I´ll study..
Cheers
Marco
I´ll study..
Cheers
Marco
- Gantois
- Posts: 90
- Joined: Thu Apr 17, 2014 9:44 am
Re: using events / miserver
Could you give some more details about what you are trying to accomplish? Are you looking to cleanly terminate a user session? Gather statistics? Something else?
The relevant event would be onbeforeunload, but for security reasons callbacks (and other actions too) are not allowed on this event, only a simple value like
or a function that returns a simple value
It used to be that the returned value would be displayed, as if executing
which you could achieve in MiServer with
However, all the major browsers (except for IE) have recently ceased to support custom messages. You can still set the attribute with the above code, but only a default message will be displayed, and the user may even have a setting that suppresses such messages too.
Now, while you cannot fully automate a callback on leaving your page or site, you may be able to accomplish what you want with a "Log Out" button/link.
If you just want to know that the user switched to a different page in your site, you can begin all pages by checking if the user just came from another page.
Here are two sample pages on miserver.dyalog.com, demostrating callback techniques:
* Callbacks
* Targets
The relevant event would be onbeforeunload, but for security reasons callbacks (and other actions too) are not allowed on this event, only a simple value like
- Code: Select all
<body onbeforeunload="return 'Write something clever here...'">
or a function that returns a simple value
- Code: Select all
<body onbeforeunload="return return myFunction()">
<script>function myFunction() {return "Write something clever here...";}</script>
It used to be that the returned value would be displayed, as if executing
- Code: Select all
alert("Write something clever here...");
which you could achieve in MiServer with
- Code: Select all
∇Compose
:Access Public
'onbeforeunload'⎕THIS.Body.Set'return ''Write something clever here...'''
However, all the major browsers (except for IE) have recently ceased to support custom messages. You can still set the attribute with the above code, but only a default message will be displayed, and the user may even have a setting that suppresses such messages too.
Now, while you cannot fully automate a callback on leaving your page or site, you may be able to accomplish what you want with a "Log Out" button/link.
If you just want to know that the user switched to a different page in your site, you can begin all pages by checking if the user just came from another page.
Here are two sample pages on miserver.dyalog.com, demostrating callback techniques:
* Callbacks
* Targets
-
Adam|Dyalog - Posts: 143
- Joined: Thu Jun 25, 2015 1:13 pm
Re: using events / miserver
Hi Adam. Only now I am seeing your explanation.
I want avoid exit one page clicking on upper right symbol ("X") giving a message and remaining on the page. (I don´t know javascript).
I'll read the cases you wrote and try solve this.
Thanks very much
I want avoid exit one page clicking on upper right symbol ("X") giving a message and remaining on the page. (I don´t know javascript).
I'll read the cases you wrote and try solve this.
Thanks very much
- Gantois
- Posts: 90
- Joined: Thu Apr 17, 2014 9:44 am
Re: using events / miserver
Hi Gantois,
I'm still not entirely sure what effect you want. Is it one of the following?
1. Prevent the user from closing the browser. If he tries, issue a message to him.
2. Allow the user to close the browser. If he does this, let the server be notified.
I'm still not entirely sure what effect you want. Is it one of the following?
1. Prevent the user from closing the browser. If he tries, issue a message to him.
2. Allow the user to close the browser. If he does this, let the server be notified.
-
Adam|Dyalog - Posts: 143
- Joined: Thu Jun 25, 2015 1:13 pm
Re: using events / miserver
Hi Adam,
it is the case one:
1. Prevent the user from closing the browser. If he tries, issue a message to him
I have one specific page in my application with one button to close it. It is necessary that the user click it to exit this page. Some actions must be processed before changing to another page or close this page.
In other words, if I Prevent the user from closing the browser I think my problem will be solved. Could I hide the close browse option x" ?. If not, I would like to show a message asking the user to click the exit button of this page.
Cheers
it is the case one:
1. Prevent the user from closing the browser. If he tries, issue a message to him
I have one specific page in my application with one button to close it. It is necessary that the user click it to exit this page. Some actions must be processed before changing to another page or close this page.
In other words, if I Prevent the user from closing the browser I think my problem will be solved. Could I hide the close browse option x" ?. If not, I would like to show a message asking the user to click the exit button of this page.
Cheers
- Gantois
- Posts: 90
- Joined: Thu Apr 17, 2014 9:44 am
Re: using events / miserver
I'm sorry to disappoint you, but you cannot take control of a visitor's computer through a website. He will always have the option to close his browser. When the user enters your site, you can inform him with a modal dialog that he must click the Exit button to save his changes, etc.
If the user nevertheless tries to close his browser with the [x] button, you can try to pop up a generic message asking if he is sure. You cannot not rely on a custom message getting through, and some users may not see any message at all.
Note that this is not a MiServer limitation, but a universal restriction on websites which is in place so that malicious websites cannot prevent users from leaving.
If the user nevertheless tries to close his browser with the [x] button, you can try to pop up a generic message asking if he is sure. You cannot not rely on a custom message getting through, and some users may not see any message at all.
Note that this is not a MiServer limitation, but a universal restriction on websites which is in place so that malicious websites cannot prevent users from leaving.
-
Adam|Dyalog - Posts: 143
- Joined: Thu Jun 25, 2015 1:13 pm
Re: using events / miserver
Note that you DO have an opportunity to clean up when the session handling code times out after a period of inactivity: You can override the onSessionEnd method of the MiServer class and insert your own code to disconnect from databases, close component files and clean up caches etc at that point.
-
Morten|Dyalog - Posts: 460
- Joined: Tue Sep 09, 2008 3:52 pm
Re: using events / miserver
thank you for your clarifications.
Marco
Marco
- Gantois
- Posts: 90
- Joined: Thu Apr 17, 2014 9:44 am
10 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group