Doz*_*ent 11 javascript logout cordova
我将在我的PhoneGap应用程序中实现注销按钮,该应用程序将用户返回到认证页面(带有已清除的字段).对于按钮我正在使用onclick事件的锚点:
<script type="text/javascript">
function doLogout() {
var backlen = history.length;
history.go(-backlen);
window.location.replace("index.html");
}
</script>
<a data-role="none" href="#" onclick="doLogout"></a>
Run Code Online (Sandbox Code Playgroud)
但它不起作用,即它只是让我回到已经填充的文件的认证页面,似乎只是后退一步.我不确定history.clear(),因为谷歌搜索它没有给我任何东西:
<a data-role="none" href="index.html" onclick="javascript:history.clear();"></a>
Run Code Online (Sandbox Code Playgroud)
谁能告诉我我的问题在哪里?如果有其他解决方案来处理PhoneGap中的注销事件,我会遵循它.谢谢
Guf*_*ffa 14
呼叫history.go
将被忽略,因为您将返回比历史记录中的项目更多的步骤.该length
属性包含当前项目的项目数,因此如果历史记录中有四个项目,则只能返回三个步骤.
要返回第一步,您将从长度中减去一个:
history.go(-(history.length - 1));
Run Code Online (Sandbox Code Playgroud)
但是,如果您专门为该页面打开一个新窗口,那么只会将您带回到起始页面.否则,它将使用户返回到他使用该窗口访问的第一页.
对象没有clear
方法history
.
参考:https://developer.mozilla.org/en-US/docs/DOM/window.history
浏览器历史记录属于用户,您无法从中删除任何内容.
归档时间: |
|
查看次数: |
56562 次 |
最近记录: |