如何使用 hashbang?
有谁可以告诉我该怎么做吗?这是我在这里用于动态加载内容的调用:
jQuery(document).ready(function($) {
function load(num) {
$('#pageContent').load(num +".html");
}
$.history.init(function(url) {
load(url == "" ? "1" : url);
});
$('#bbon a').live('click', function(e) {
var url = $(this).attr('href');
url = url.replace(/^.*#/, '');
$.history.load(url);
return false;
});
});
它使用 jQuery 来启动历史记录插件。可以修改它以某种方式使用 hashbang 吗? 我读过很多文章,但没有给您提供如何执行此操作的示例。
Is there anyone who can tell me how to do this? This is the call I use here for loading content dynamically:
jQuery(document).ready(function($) {
function load(num) {
$('#pageContent').load(num +".html");
}
$.history.init(function(url) {
load(url == "" ? "1" : url);
});
$('#bbon a').live('click', function(e) {
var url = $(this).attr('href');
url = url.replace(/^.*#/, '');
$.history.load(url);
return false;
});
});
It uses jQuery to initiate the history plugin. Can this be modified to somehow use the hashbang?
I've read a lot of articles but nothing gives you an example of how to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下 hashbang 的示例http://www.amitpatil.me/create-gmail-like-app-using-html5-history-api-and-hashbang/
Have a look at this example for hashbang http://www.amitpatil.me/create-gmail-like-app-using-html5-history-api-and-hashbang/
问题的原始版本询问“hashbang/shebang”。
什么是 shebang
在类 Unix 系统上,脚本(文件)以 shebang 如果它以字符“#”(散列)和“!”开头(bang):
(例如),那么内核知道使用参数
perl
运行程序/usr/bin/env
,从而在脚本上运行 Perl 解释器这是在命令行上指定的。因此,如果这是文件xyz.pl
的第一行,那么 Perl 将被赋予xyz.pl
作为其标准输入。AFAIK,这仅在执行程序/脚本时有效。
我不太了解如何运行 Javascript 或 JQuery,但如果它要工作,你必须能够将这样的东西放在文件的顶部(这也需要执行(并且read) permssion on the file):
但是,这个问题似乎与 Ajax 代码中的标记有关,并且术语 shebang 可能不应该用于此目的。
The original version of the question asked about 'hashbang/shebang'.
What is a shebang
On Unix-like systems, a script (file) starts with a shebang if it starts with the characters '#' (hash) and '!' (bang):
(for example), then the kernel knows to run the program
/usr/bin/env
with the argumentperl
, thus running the Perl interpreter on the script that is specified on the command line. So, if that was the first line of a filexyz.pl
, then Perl will be givenxyz.pl
as its standard input.This only works, AFAIK, when a program/script is executed.
I don't know enough about how you might be running Javascript or JQuery, but if it was going to work, you'd have to be able to put something like this at the top of a file (which would also need execute (and read) permssion on the file):
However, this question seems to be about marks within Ajax code, and the term shebang probably shouldn't be used for this.