Is there some开发者_运维百科 way I can tell whether window.location.hash
is defined?
If it is set, then I will be getting the value of the variable, and using it to display extra content on the page.
if(window.location.hash) {
// do stuff!
}
How about:
if(window.location.hash !== '')
{
}
Or
if(typeof window.location.hash !== 'undefined')
{
//your code
}
精彩评论