Javascript 解析来自ajax调用jquery的URL哈希

Javascript 解析来自ajax调用jquery的URL哈希,javascript,Javascript,假设我有这个脚本 $('body').load('someurl.html#12', function(data){ // my code to proccess data }); 在someurl.html中,如何获取此URL的哈希?在这种情况下,应为12。当我尝试使用window.location.hash解析它时,我得到的当然是没有哈希的父URL。这可以使用jQuery BBQ来完成 从URL解析查询字符串或片段 “someurl.html12”.split[1]?重复@user

假设我有这个脚本

$('body').load('someurl.html#12', function(data){
    // my code to proccess data
});

在someurl.html中,如何获取此URL的哈希?在这种情况下,应为12。当我尝试使用window.location.hash解析它时,我得到的当然是没有哈希的父URL。

这可以使用jQuery BBQ来完成

从URL解析查询字符串或片段


“someurl.html12”.split[1]?重复@user3678068:是的,我知道如何分割散列,我的问题是当我在someurl.html中解析URL时,值不是someurl.html,而是index.htmlwindow.location包含运行脚本的页面的URL,不是它加载的任何东西。@Barmar:那么我如何在加载的文件中获取哈希值,知道吗?
The jQuery.param.querystring and jQuery.param.fragment methods can be used to return a normalized query string or fragment from the current document or a specified URL. Complete usage information is available in the documentation.

// Return the document query string (similar to location.search, but with
// any leading ? stripped out).
var qs = $.param.querystring();

// Return the document fragment (similar to location.hash, but with any
// leading # stripped out. The result is *not* urldecoded).
var hash = $.param.fragment();

// Parse URL, returning the query string, stripping out the leading ?.
// qs is set to "a=1&b=2&c=3"
var qs = $.param.querystring( "/index.php?a=1&b=2&c=3#hello-world" );

// Parse URL, returning the fragment, stripping out the leading #.
// hash is set to "hello-world"
var hash = $.param.fragment( "/index.php?a=1&b=2&c=3#hello-world" );