Javascript issue on category pages
-
Hi
I hope someone can help. I have a background image used in a search input box, so that it’s there until someone clicks in the box to enter their text. There’s code in the footer (which is used on every page) and links to a .js file. It works fine on pages that are only one level deep ie ‘/about’, ‘/contact’, ‘/name-of-post’ but if it’s more than that it won’t work ie ‘/category/business’, ‘/page/2’, ‘/2010/09’.
Below is the js used, I’m hoping someone can see an issue with it that would cause this problem. Thanks.
(function() { var id = document.getElementById('search-form'); if (id && id.s) { var name = id.s; var unclicked = function() { if (name.value == '') { name.style.background = '#FFFFFF url(/wp-content/themes/mytheme/images/search-this-site.png) left no-repeat'; } }; var clicked = function() { name.style.background = '#ffffff'; }; name.onfocus = clicked; name.onblur = unclicked; unclicked(); } })();
The topic ‘Javascript issue on category pages’ is closed to new replies.