8114 posts Community Moderator
  • Attended a Community Meetup
  • Community Moderator
  • Has been a member for 6-7 years
  • United Kingdom
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Contributed a Blog Post
  • Beta Tester
  • Bought between 50 and 99 items
+4 more
MSFX Volunteer moderator says

Sorry this is in all marketplaces but theres no “corner” for developers to discuss things :(

So, this is targeted at AD / CC and TF users…

I’ve made an online application in Flash where users can login, perform tasks etc etc… the backend is all ZendAMF (php)...

There is a logout button but should they not click it and just go and close the window whats the quickest most guaranteed method for logging them out?

I could use ExternalInterface within Flash which allows Flash and JS comms (tested in all browsers) and listen for the window.onunload event and then call the flash to invoke ZendAMF to log them out but is there a quicker way, this seems a little long winded…

Also window.onunload doesn’t appear to be thrown in safari / opera on W7 ?? :( (it works within FF 3 .6, IE8 and Chrome)

Anyone got any ideas / tuts / files that could handle this functionality or an alternative approach?

Cheers

Matt / MSFX

1666 posts Time is what you desire most, but waste carelessly.
  • Sold between 100 000 and 250 000 dollars
  • Elite Author
  • Bought between 50 and 99 items
  • Referred between 100 and 199 users
  • Grew a moustache for the Envato Movember competition
  • Exclusive Author
  • Has been a member for 4-5 years
  • Microlancer Beta Tester
  • Europe
+1 more
Firsh says

maybe session timeout? or I’m completely wrong about what’s going on..

8114 posts Community Moderator
  • Attended a Community Meetup
  • Community Moderator
  • Has been a member for 6-7 years
  • United Kingdom
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Contributed a Blog Post
  • Beta Tester
  • Bought between 50 and 99 items
+4 more
MSFX Volunteer moderator says
maybe session timeout? or I’m completely wrong about what’s going on..

isn’t that client side though? when they close the browser the session ends?

I basically need to server to detect that the user has left without logging out…

812 posts
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
  • Serbia
  • Has been a member for 5-6 years
rvision_ says

you can try with jQuery, it probably works with all browsers:

$(window).unload( function () { alert(“Bye now!”); } );

but this way you should call flash from javascript, not other way around (I don’t know about ExternalInterface details, but I’m sure it can be worked out)

4136 posts
  • Bought between 1 and 9 items
  • Brazil
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • Sold between 5 000 and 10 000 dollars
tsafi says

The code that i gave you didn’t work for you?

8114 posts Community Moderator
  • Attended a Community Meetup
  • Community Moderator
  • Has been a member for 6-7 years
  • United Kingdom
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Contributed a Blog Post
  • Beta Tester
  • Bought between 50 and 99 items
+4 more
MSFX Volunteer moderator says
The code that i gave you didn’t work for you?

that was for popups… and for several browsers no it wouldn’t work :(

you can try with jQuery, it probably works with all browsers:

jQuery is javascript, if regular javascript doesn’t catch it how would jQuery?

812 posts
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
  • Serbia
  • Has been a member for 5-6 years
rvision_ says
The code that i gave you didn’t work for you?

that was for popups… and for several browsers no it wouldn’t work :(

you can try with jQuery, it probably works with all browsers:
jQuery is javascript, if regular javascript doesn’t catch it how would jQuery?

Because javascript has browser-specific events/quirks/etc. and jquery knows about them :)

8114 posts Community Moderator
  • Attended a Community Meetup
  • Community Moderator
  • Has been a member for 6-7 years
  • United Kingdom
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Contributed a Blog Post
  • Beta Tester
  • Bought between 50 and 99 items
+4 more
MSFX Volunteer moderator says
Because javascript has browser-specific events/quirks/etc. and jquery knows about them :)

unfortunately not :(

Still works in FF, IE8 and Chrome… no luck in Opera or Safari :x :(
(oddly this was also the case with popups)

http://msfx.co.uk/temp/jquery/
(closing the page should give an alert)

Any other ideas?

812 posts
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
  • Serbia
  • Has been a member for 5-6 years
rvision_ says

You’re right, doesn’t work in opera :(

Events The unload event is not fired. It’s a limitation of Opera, you can report it here. The example below doesn’t work.

$(document).ready( function() { $(window).unload(function(){ alert(“ok”) }) } )

http://docs.jquery.com/Known_Issues

8114 posts Community Moderator
  • Attended a Community Meetup
  • Community Moderator
  • Has been a member for 6-7 years
  • United Kingdom
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Contributed a Blog Post
  • Beta Tester
  • Bought between 50 and 99 items
+4 more
MSFX Volunteer moderator says
You’re right, doesn’t work in opera :(

does it work in Safari for you?

by
by
by
by
by
by