Jump to content

Recommended Posts

I want to send an ajax request to refresh a certain line in my site every time the window is focused, and it's giving me a major headache because neither this

function() {
    $(window).focus(function() {
        alert("Thanks for visiting!");
    };
});

nor this

$(window).focus( function() {
	alert("Thanks for visiting!");
});

alert anything :@

Link to comment
https://forums.phpfreaks.com/topic/244393-jquery-headache/
Share on other sites

actually I can, the problem was, as always the dumbest crap, I forgot to include the jquery file... and the code if someone needs it is as follows:

 

var returning = 0;
$(window).focus( function() {
	if(returning==1)
		{
		alert("Thanks for visiting!");
		returning = 0;
		}
});
$(window).blur( function() {
	returning = 1;
});

Link to comment
https://forums.phpfreaks.com/topic/244393-jquery-headache/#findComment-1255203
Share on other sites

seems buggy in FF5.0 + jQuery v1.6.2

 

I have that on a test page and have it in one tab, and another tab to some other random place, and when I keep clicking back and forth between the two tabs, I seem to be only getting the alert every other focus.

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/244393-jquery-headache/#findComment-1255371
Share on other sites

It should be buggy, from the manual:

 

This event is implicitly applicable to a limited set of elements, such as form elements (<input>, <select>, etc.) and links (<a href>). In recent browser versions, the event can be extended to include all element types by explicitly setting the element's tabindex property.
Link to comment
https://forums.phpfreaks.com/topic/244393-jquery-headache/#findComment-1255610
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.