Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

How to fire an event without a button on the webserver?

If you have a question or need help, this is the place to be.
Post Reply
Tomkun
Posts: 22
Joined: Wed Sep 14, 2011 4:40 am

How to fire an event without a button on the webserver?

Post by Tomkun »

Hello.

I am using the EventGhost webserver and so far it's working great. I am a little stuck on how to get events to fire without a button though. I want to use onbeforeunload to fire an event when somebody closes the browser or navigates to another page. So far I have this:

Code: Select all

<script>
function closeIt()
{

}
window.onbeforeunload = closeIt;
</script>
But I don't know what to put in the { } to fire an event.

I hope you can understand what I mean and am trying to do. Could anybody help me?
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: How to fire an event without a button on the webserver?

Post by krambriw »

You can try the attached html page, it works for me. When I close the page, I receive an event in EG as expected.

Best regards, Walter
example.zip
(629 Bytes) Downloaded 329 times
Tomkun
Posts: 22
Joined: Wed Sep 14, 2011 4:40 am

Re: How to fire an event without a button on the webserver?

Post by Tomkun »

Thank you very much! I'll try it now.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: How to fire an event without a button on the webserver?

Post by Pako »

Dear Walter!
I (completely independently of you) reached a very similar solution.
However, there are some differences:
1. I chose the POST method.
2. I did not deal with the different compatibility of the different browsers. My solution only works with Chrome and Firefox (and partly Opera). Opera does not support onbeforeunload event (so it can not work with you too).
3. My solution allows the user to submit events when navigate to another page (for each page you can select another event).

Pako
Attachments
WebserverDemo.jpg
PakoExample.zip
(1.1 KiB) Downloaded 333 times
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: How to fire an event without a button on the webserver?

Post by krambriw »

Dear Pako,

This is funny, yes really a coincidence!

You are right, my suggestion I tested only in Chrome, I picked some old simple code I had since before.

Your sample is much better and more advanced, really nice!

My kindest regards, Walter
Post Reply