使用jQuery从URL读取#hash [英] Read #hash from URL with jQuery

查看:315
本文介绍了使用jQuery从URL读取#hash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jQuery从URL返回website.com/#something的哈希值?

How can I return the hash value of website.com/#something (something) from the URL with jQuery?

推荐答案

window.location.hash 就这么简单.

不要使用所有消耗CPU并影响性能的方法.

donot use all those methods which consume CPU and effects performance.

如果DOM提供了预定义的内容,请先使用它.

If DOM provides something predefined use it first.

要将值传递给PHP,请执行并ajax调用php.

To pass value to PHP please do and ajax call to php.

var hash = window.location.hash;

$.ajax({
    url: 'someurl.php',
    data: {hash: hash},
    success: function(){}
})

这篇关于使用jQuery从URL读取#hash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆