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