-1
我想将var loadurl传递给上面的函数。我怎样才能做到这一点? (下面的代码是我的功能,我想ID传递给上面的代码任何帮助表示赞赏History.JS将var传递给上述函数
$(函数(){
// Prepare
var History = window.History; // Note: We are using a capital H instead of a lower h
if (!History.enabled) {
// History.js is disabled for this browser.
// This is because we can optionally choose to support HTML4 browsers or not.
return false;
}
// Bind to StateChange Event
History.Adapter.bind(window,'statechange',function() { // Note: We are using statechange instead of popstate
var State = History.getState();
console.log(loadurl);
$('#test').load(loadurl);
/* Instead of the line above, you could run the code below if the url returns the whole page instead of just the content (assuming it has a `#content`):
$.get(State.url, function(response) {
$('#content').html($(response).find('#content').html()); });
*/
});
// Capture all the links to push their url to the history stack and trigger the StateChange Event
$('a').click(function(evt) {
evt.preventDefault();
var loadurl = $(this).attr('id');
History.pushState(loadurl, $(this).text(), $(this).attr('onclick'));
});
});