0

Ok it seems ive stumbled on another JQuery problem but i think this is more off a browser problem. The code below seems to work fine in All browsers apart from IE7 & Opera

function inputs() {
$('#search').css({opacity: .25}).hoverIntent(   function() { 
                                $(this).stop(true,true).animate({opacity: 1}, 500 );
                            },
                            function() {
                                if(!$('#mod_search_searchword').is(':focus') ) {
                                    $('#search').stop().delay(500).animate({opacity: .25}, 500 );
                                }
                            }
                        );
$('#search').focusout(function(){$(this).stop(true,true).animate({opacity: .25}, 500 );});

}

The effect is simple... I just want it so that once the search input field is hovered to raise its opacity then when its hovered out to revert back to original opacity, but if the input field is active to not execute the hoverout till they focus out. But for some reason :focus doesnt seem to be recognised by opera or IE7. Is there a work around?

Edhen
  • 345
  • 4
  • 15
  • Ok after hours off brainstorming I finally came up with a solution and honestly i cant beleive it took me this long to realize it... but for anyone with the same issue... i had just declared a var = false.. then if focusin is initiated to then turn the var into true where the hover will then have and if (var == false) to exceute fade else do nothing... – Edhen Feb 27 '11 at 12:46
  • :focus has never worked in IE7 and was only supported in IE8. It works in Opera so I don't know what the issue is there. – Rob Feb 27 '11 at 17:36
  • Yh i didn't understand that either regarding Opera, And i know of IE7 not supporting it but i was gather JQuery might had interperated it differently or something. Mind you i'm very new to javascript and just trying to compare a value or bool was becoming more difficult then it should.. – Edhen Feb 27 '11 at 23:42

2 Answers2

0

Try this out.

setTimeout(function() { document.getElementById('mod_search_searchword').focus(); }, 10);

or you can also use :active

Rahul Arora
  • 1,036
  • 9
  • 8
  • I dont think that solution is what im after. I dont wish to force a focus... I just want safari and IE7 to know if its focused or not... i also tried the :active but that too didnt work – Edhen Feb 27 '11 at 09:27
  • This is a guess. And i m not sure whether it will work or not. If (:active) then setTimeout(). – Rahul Arora Feb 27 '11 at 09:49
  • Nop still no go, Ive tried many different combinations without success... My god javascript is becoming the most clumsiest scripting language i have came across... I tell it this and it completely doesnt understand the simple logic. Also just making if conditions just seems impossible for some elements, I guess i cant blame the language as much as i can blame the browsers programmers tho... Either they pick up there Sh@% and stick to standards or 1 browser dominates all... till then, we will always be in these sites looking for solutions – Edhen Feb 27 '11 at 10:39
0

I did not find the :focus selector in the latest jQuery docs.

You have to extend jQuery to use this feature.Answered here

Community
  • 1
  • 1
krishna
  • 1,366
  • 2
  • 15
  • 23
  • thanks for the answer and your right... but i swear i saw it in the Docs... but i must had just fiddled around too much subconsciously thinking it was there or so.. Yet it worked for all browsers except Opera & IE7 so there must be some truth to it... Anyways im trying to limit the overhead of plugins being loaded and my solution with a couple extra lines beats a couple hundred from a plugin.. Thanks tho – Edhen Feb 27 '11 at 23:39