0
Basically I have a jQuery code that should show the widgets on a certain page of my website (their property would be #left, #right) only it’s not working and I can’t figure out why. Here’s the code I’m using:
jQuery(document).ready(function(){
if(location.pathname=='/forum'){
jQuery('#left,#right').show()
}
});
I use to show the widgets only on the page and to hide them from the other pages I use this CSS:
#left,#right{display:none}
Could anyone see what is wrong? Thanks in advance.
What is returning in Location.pathname when you access the forum page?
– Jeferson Assis
Only thing that is returning is this: Uncaught Syntaxerror: Unexpected Identifier VM93:1 'webkitIDBObjectStore' is deprecated. Please use 'Idbobjectstore' Instead.
– Fábio Ferreira
Apparently the error is not in your code snippet, maybe some other function is giving error.
– Jeferson Assis
Fábio, can you debug from the browser console? If there are errors in the console they may be preventing your code from running. Always look for your code, makes it easy to find possible errors. Another tip if you don’t know how to debug from the console is to put an Alert("") before the "jQuery() function. show()", to make sure that you are entering the if.
– Joao Paulo
There are two errors as mentioned above: Uncaught Syntaxerror: Unexpected Identifier VM93:1 'webkitIDBObjectStore' is deprecated. Please use 'Idbobjectstore' Instead.
– Fábio Ferreira
These errors are sometimes in another js file and pass beaten. Ideally you debug your code.
– Joao Paulo
Fábio, that
Uncaught SyntaxError
disappeared?– Sergio
Yes Sergio! : D Very strange.
– Fábio Ferreira
Fabio: and it returns if you take window from window.location.pathname?
– Sergio
Yes, that’s why I find it very strange.
– Fábio Ferreira
It really doesn’t make sense.
location
is a global variable, can be accessed with or withoutwindow.
. Unless there’s another, local, with the same name and in the scope you’re in.– bfavaretto