HTML迷你浏览器后退按钮禁用 [英] HTML mini browser back button disabling

查看:112
本文介绍了HTML迷你浏览器后退按钮禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下网页:

 <!Doctype html> 
< html>
< head>
< script>
函数display(value){
document.getElementById('displaysyer')。src = value;
返回false;
}
< / script>
< / head>
< body>
< form name =xonsubmit =return display(this.y.value)>
< input name =y/>< input type =submitvalue =display/>
< / form>
< iframe id =displaysyer> ERROR< / iframe>
< button onclick =document.getElementById('displaysyer')。contentWindow.history.back()>点击我回到iframe的历史!< / button>
< / body>
< / html>

和后退按钮可以正常工作,但是当有人到达他们开始的页面时(在iframe中)并且他们点击后退按钮,它们将他们带到他们在整个浏览器窗口中访问的上一页。我怎么能不知何故禁用后退按钮,当有人到达他们开始的页面?



我可以通过使用文本框中的值跟踪他们开始的页面,但如何知道目前正在iframe中访问哪个页面?



如果我能够知道哪个页面当前正在iframe中访问,那么我可以轻松地将条件语句禁用按钮......



我试过了:

文档。 getElementById(displaysyer)。contentWindow.location.href



但它给了我undefined!



我正在使用google chrome最新版本的ubuntu 12.10。

请帮助...

解决方案

编辑



p>

当某人到达他们开始的页面时,我该如何禁用后退按钮?



< blockquote>

Y ou不能。


如何知道当前在iframe中访问哪个页面?


在这种情况下,没有办法。


出于安全原因,就像您无法从网站外的来源获取AJAX内容一样,如果您的网站外部无法获取 iframe url 。


i have the following webpage:

<!Doctype html>
<html>
<head>
<script>
function display(value){
document.getElementById('displayer').src=value;
return false;
}
</script>
</head>
<body>
<form name="x" onsubmit="return display(this.y.value)">
<input name="y" /><input type="submit" value="display"/>
</form>
<iframe id="displayer">ERROR</iframe>
<button onclick="document.getElementById('displayer').contentWindow.history.back()">Click me to go back in the history of iframe!</button>
</body>
</html>

and the back button works fine, but when someone reaches the page they started with (in the iframe) and they click the back button it takes them to the previous page they visited in the whole browser window. how can i somehow disable the back button when someone reaches the page they started with?

i can keep track of the page they started with by using the value in the textbox, but how to know which page is currently being visited in the iframe?

if i can know which page is currently being visited in the iframe then i can easily put a conditional statement to disable the button...

i've tried:

document.getElementById("displayer").contentWindow.location.href

but it gives me undefined!

i am working on ubuntu 12.10 on google chrome latest version.

please help...

解决方案

EDIT

Answers to both questions asked:

how can i somehow disable the back button when someone reaches the page they started with?

You can't.

how to know which page is currently being visited in the iframe?

In this case, there isn't a way.

For security reasons, just like you can't fetch content with AJAX from a source outside your site, you can't get the iframe url if outside your site.

这篇关于HTML迷你浏览器后退按钮禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆