1
我学习技术:历史API pushState的(HTML5)pushState的:如何添加查询字符串没有重定向
我需要为工作的网址重定向withput因为我有服务器的CherryPy的命令。
我无法从Cherrypy传输数据(使用Mako模板转换为Javascript),但我想更改网址。
旧网址是
file:///media/DATA/prototypefin4/s.html
并在URL自动添加foo=1&foo=2
(变量s)与History.pushState
file:///media/DATA/prototypefin4/s.html?=foo=1&foo=2
但如何?
我的代码:
<!DOCTYPE HTML>
<html>
<head>
<title>Example - History API pushState</title>
</head>
<script src="http://balupton.github.com/history.js/vendor/jquery.js"></script>
<script src="http://balupton.github.com/history.js/scripts/bundled/html4+html5/jquery.history.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
<body>
<input id = 'button1' type = 'button' value = 'history.pushState' onclick="updateHistory()"/>
<script type = 'text/javascript'>
var count ="?foo=1&foo=2";
function updateHistory()
{
History.pushState(count,null,file:///media/DATA/prototypefin4/s.html);
}
</script>
</body>
</html>
这是否可能?我可以看到它的一些问题。 – 2013-03-24 12:35:12
我认为可能的错误是在History.pushState(count,null,file:///media/DATA/prototypefin4/s.html); 因为在论坛中有评论 我在没有服务器的情况下使用我的电脑。 解决方案是什么? – 2013-03-24 12:44:26
“我在没有服务器的情况下使用我的电脑,解决方案是什么?” - 安装[Apache](http://httpd.apache.org/)。 – Quentin 2013-03-25 15:46:08