获得哈希URL从锚和加载到事业部事业部、加载、URL

由网友(ζ 柔*陌殇丷)分享简介:我有一个视频库,有左边的菜单,并加载内容插入右侧一个div。从PHP的视频帖所产生的菜单,所以我们需要一个通用脚本,将影响一切。I have a video gallery that has a menu on the left and loads the content into a div on the righ...

我有一个视频库,有左边的菜单,并加载内容插入右侧一个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 -

如:

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.

阅读全文

相关推荐

最新文章