我有一个具有按钮的Web应用程序,如果点击将转到特定的历史记录。我听说只有IE支持history.go(url),但其他浏览器只接受数字值。在我的情况下,history.go()将仅转到特定页面。 http://localhost:54187/Products/Create
。即使用户导航到不同的页面,如果按钮被点击,仍然会进入“创建”历史页面。我需要history.go,因为它相当于浏览器的后退和前进。我无法使用window.location或location.href,因为我的应用程序要求填充数据仍然存在history.go的确切含义。如果用户总共加载了26页,我将如何知道这26个页面中的哪一个是创建页面,以便我可以创建history.go(createIndex)? window.history.length给出26但它不公开URL。history.go()如何从window.history获取特定访问页面url的索引?
请帮助我如何解决我的问题。
JavaScript和HTML
<script type="text/javascript">
$(document).ready(function() {
$('#btnGoToCreate').click(function() {
var createIndex = //how to know what's the index of
//http://localhost:54187/Products/Create from window.history?
history.go(createIndex);
});
});
</script>
<input type="button" value="Go to Last Entry" id="btnGoToCreate" />
_“我不能使用window.location或location.href,因为我的应用程序要求填充数据仍然存在” - 这更像是缓存而不是页面导航到的_how_。如果您需要再次输入用户输入的数据,则应将其保存到会话中,以便您可以从此处读取。 – CBroe 2013-03-26 08:47:19
@CBroe伟大的建议 – 2013-03-26 08:52:15