fra*_*kie 0 javascript hash jquery
我的网站包含所有动态加载的内容.
我写了一些JS函数,根据收到的URL更改内容.如果有人访问www.mysite.com/#1056,将加载该内容.
function getLocationHash() {
//check if there is a location hash in the address bar, get that URL
if (window.location.hash != '') {
processURL()
}
}
Run Code Online (Sandbox Code Playgroud)
然后它调用processURL函数
function processURL() {
if (window.location.hash != '') {
urlHash = window.location.hash;
//if it's a catalog item, it has a number above #1000
if (urlHash > 10000) {
getDetail(urlHash);
}
Run Code Online (Sandbox Code Playgroud)
这适用于历史记录或直接跳转到网站上的URL - 但是,其他网站不能遵循这一点.例如,如果我将www.mysite.com/#1056输入Facebook状态,FB只会搜索www.mysite.com索引页面.它没有贯穿JS的末尾.这是因为JS正在寻找'窗口'属性吗?
Google抓取也是如此.我设置了包含所有哈希网址的站点地图,但Google只会抓取索引页面.
所以问题是:我如何利用我在这里所拥有的内容并正确格式化Facebook和谷歌等其他服务可以"看到"的URL?
任何提示将非常感激.
| 归档时间: |
|
| 查看次数: |
59 次 |
| 最近记录: |