Help with jQuery code?

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
ghillerson
Propeller Head
Posts: 85
Joined: Wed Mar 05, 2014 10:22 pm
Location: Near Santa Cruz, CA
Contact:

Help with jQuery code?

Post by ghillerson »

Hi,

We're seeing problems with search not working some of the time. Specifically, customers using Chrome or MacOS search for a term and get back a results page that shows no results; if they then do a refresh and search again, they get the expected results. I'm assuming this must be a cache issue, and that Chrome and MacOS don't play together so well in this regard, but I need to fix the problem: most of our customers are Mac/Chrome users.

The best possibility I can see is to add some jquery code that triggers when the searchbar gets the focus and does a page refresh before the user types anything. I'm guessing the same code would have to then make the searchbar the focus without triggering the code again.

Can anyone help with this?
- does it seem like a reasonable approach, or can someone come up with a better solution?
- can anyone come up with the jquery code I'd need to add and which selector to use?

Any help/suggestions appreciated.

Gary
kwag_myers
Propellus Maximus
Posts: 810
Joined: Wed Jul 25, 2012 11:36 am
Location: Ann Arbor, MI

Re: Help with jQuery code?

Post by kwag_myers »

I did something similar to this with reload (Reloading The Page). It's not jQuery, but might give you something to build from.

I also had a design that called for the Search Bar to be hidden until the icon was clicked (why people insist on hiding things from users is beyond me). I'm wondering if you can use this JS to set the focus on Search? You may need to add /*<![CDATA[*/ and /*]]>*/ inside the <script> tags.

Code: Select all

<script type="text/javascript">
    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }
</script>


Simply paste the above snippet of code within the <head> tags and you call it by passing to it the ID of the element you wish to toggle the visibility of (this element can be anything that takes an id attribute). For example: 

<a href="#" onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</a>


<div id="foo">This is foo</div> or <div id="foo" style="display: none;"> to hide initially.
I hope this helps.
"I'm tryin' to think, but nothin' happens!" - Curly Joe Howard
Post Reply