php - 如何使子导航不影响父浏览器历史记录?

标签 php javascript html ajax browser

我有一个主页,其中包含一个简单的 iframe。 iframe 源 = 一个 php 文件。 PHP 有一个用户可以点击的链接,但只要点击,浏览器历史记录就会增加。

我希望 iframe 是独立的,不影响历史记录。 可能的?我不熟悉 ajax 顺便说一句。

PS:它在iframe中只有1个链接可以点击。

谢谢

最佳答案

我唯一想到的就是使用 location.replace单击链接时更改 iframe 中的 URL。

该方法不会将当前页面存储在浏览器的 session 历史记录中,例如:

<a href="http://google.com"
   onclick="location.replace(this.href);return false;"/>Google</a>

或以编程方式连接事件:

<a href="http://google.com" id="linkId">Google</a>

...

document.getElementById('linkId').onclick = function () {
  location.replace(this.href);
  return false;
};

检查示例 here .

关于php - 如何使子导航不影响父浏览器历史记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1884174/

相关文章:

python - 从 html 表制作数据框时,可以在 pandas read_html 中保留换行符吗?

php - 如何在使用 mysqli_multi_query 时进行 mysqli_fetch_row

php - 在 Twig View 预渲染中设置变量

php - 启动Xampp时MySql崩溃了?

javascript - 奇怪的表单重置事件行为

javascript - 如果我们创建新的原型(prototype)属性,对象会改变它的隐藏类吗?

html - 移动菜单下拉问题

PHP : How to remove images in the directory of my website using PHP

javascript - 在javascript中将百分位转换为 “minutes:seconds.hundredths”

html - CSS 复选框重复