开发者

Javascript window.location.hash is defined?

开发者 https://www.devze.com 2023-01-23 16:01 出处:网络
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.

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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号