Jump to content

Jquery headache


manix

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.