gpt4 book ai didi

javascript - 为什么元素隐藏但不将内容加载到 iframe

转载 作者:行者123 更新时间:2023-11-28 03:08:59 24 4
gpt4 key购买 nike

需要帮助 :) 我有一段代码,像这样:

<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='https://fonts.googleapis.com/css?family=Raleway:300' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="hexagons.css">
<script src="jquery-3.2.1.min.js"></script>
<script type="text/javascript">
// function disp(){
// document.getElementById('hexGrid').style.display = 'none';
// }
</script>
</head>
<body>
<iframe name="display" id="display_template"></iframe>

<ul id="hexGrid">
<?php
foreach ($dirs as $link) {
if ($link != 'assets') {
echo '
<li class="hex">
<div class="hexIn">
<a class="hexLink" href="'.$linkArray[$link].'" onclick="disp(); return false;" target="display" >
<img src="assets/dir.png" alt="'.$link.'" />
<h1>' . $link . '</h1>
<p>Redirect to template</p>
</a>
</div>
</li>
';
}
}
?>
</ul>
</body>

我想在链接的 onClick 上实现这一点,#hexGrid 会将显示样式更改为无,同时 iframe 将加载一些内容。

当 JS 被评论时,点击时,iframe 正确加载选定的内容,但是当 JS 处于事件状态时,它只是隐藏#hexGrid 而没有将内容加载到 iframe。

知道哪里出了问题吗? :)

最佳答案

解决方法发现应该是onclick="disp(); return true;"而不是 onclick="disp(); 返回 false;"

关于javascript - 为什么元素隐藏但不将内容加载到 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45814557/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com