html - iframe 内的内容重定向但不是整个页面
问题描述
所以我有一列里面有这个代码:
<div class="cat">
<iframe src="sidebar.html" frameborder="0" ></iframe>
</div>
这是“sidebar.html”内的一行:
<th target="_top" onclick="window.location='http://example.com'">example</th>
(请记住,这是表格的一部分)
当我点击“示例”这个词时,它实际上会重定向到它应该的位置,但这仅在 iframe 内可见
我想将整个页面重定向到 www.example.com
解决方案
只需添加“父母”。在 window.location 之前:
<th target="_top" onclick="parent.window.location='http://example.com'">example</th>
推荐阅读
- javascript - 如何使用 cypress [cypress] 选择文本
- react-native - 两种颜色的背景 - React Native
- python - Pandas str.replace 跳过一些替换
- ansible - Ansible 标准输出格式
- docker - 弹性连接错误-> Elasticsearch 6 + Kibana + Docker Compose
- javascript - 如何连接此代码?我试过这样做,但我没有运气
- java - java用户界面调用python函数?
- mysql - MySql 服务不会启动 [ubuntu]
- javascript - 带撇号的正则表达式单词搜索
- excel - AVERAGEIF() 语句中的上限值