获得哈希URL从锚和加载到事业部 [英] Get Hash URL from anchor and load into Div

查看:128
本文介绍了获得哈希URL从锚和加载到事业部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个视频库,有左边的菜单,并加载内容插入右侧一个div。从PHP的视频帖所产生的菜单,所以我们需要一个通用脚本,将影响一切。

I have a video gallery that has a menu on the left and loads the content into a div on the right hand side. The menu is generated from php video posts so we need a general script that will effect everything.

- 问题 -

该链接将加载视频的URL作为当前URL的锚 -

The links will load the URL of the video as an anchor on the current URL -

如:

<一个href="http://www.divethegap.com/update/community/videos/#http://www.divethegap.com/update/2010/10/test-video-2/" rel="nofollow">http://www.divethegap.com/update/community/videos/#http://www.divethegap.com/update/2010/10/test-video-2/

所以,我需要的是一个脚本,将得到的哈希标签和内容加载到一个div。到目前为止,我已经惨遭失败尝试做到这一点。我想这是沿着document.location.hash的线条的东西,但不知道从哪里里去。

So all I need is a script that will get the hash tag and load the content into a div. So far I have failed miserably trying to do that. I imagine it is something along the lines of document.location.hash but don't know where to go from there.

帮助多少AP preciated。

Help much appreciated.

感谢

推荐答案

注:这个答案的用户的jQuery 1.4.2,因为包含和被广泛应用在网页已经

您可以附加一个单击处理程序的锚,例如:

You can attach a click handler to the anchors, for example:

$("#nav a").click(function() {
  $("#content").load(this.hash.substring(1));
});

你可以在这里对其进行测试,对你的标记,不是会不会的实际上的负载在演示中,因为它是在一个单独的域名,但会很好地工作在同一个域。

You can test it out against your markup here, not it won't actually load in the demo since it's on a separate domain, but will work fine on the same domain.

这篇关于获得哈希URL从锚和加载到事业部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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