所以这是一个非常简单的问题,但我在解决它时遇到了困难 看到我有一个iframe,我想根据点击的链接改变它的src
这是 javascript代码
function showOverlay(id)
{
var str1 = 'abstract.php?id=';
var link = str1.concat(id);
document.getElementById(id).style['display'] = "block";
document.getElementById(id).style['opacity'] = "1";
document.getElementById('abstract_frame').src = link;
}
function hideOverlay(el, evt)
{
if (el && evt)
{
el.style.display = evt.target == el ? 'none' : '';
}
document.getElementById('abstract_frame').src = '';
}
所以我使用document.getElementById('abstract_frame').src = link;
设置src然后在我使用的hideOverlay函数上
document.getElementById('abstract_frame').src = '';
将src设置回空白链接。
所以问题是当我再次调用showOverlay来设置另一个带有不同值的iframe的src链接时我得到一个空白的屏幕
这是 html / php
echo '<div class="SearchResults">';
echo " <span class='top'>";
echo " <a>";
echo " <h3>". strtoupper($title) ."</h3>";
echo " </a>";
echo " <br />";
echo " <h5 class='sub'>";
echo "Authors :";
$tags = explode('|',$run['author']);
foreach($tags as $i =>$key) {
echo '<a class="authors">Dr.'.$key.'</a>';
}
echo "<br><br>";
echo " </h5>";
echo " </span>";
echo " <span class='bottom'>";
echo " <span class='bottomLeft'>";
echo ($run['abstract'] != "" ? " <a class='options' data-articlenum='" . $run['reference_number'] . "' onclick='showOverlay(this.dataset.articlenum)'>Abstract</a><span style='margin:0px 5px;'>|</span>" : "" );
echo " <a target='_blank' href='view.php?filename=".strtolower($run['title'])."' class='options'>";
echo " Full Article";
echo " </a>";
echo " </span>";
echo " <div class='overlay' id='". $run['reference_number'] ."' onclick='hideOverlay(this, event)'> ";
echo " <iframe class='abstract' id='abstract_frame' style='padding:0px;' scrolling='no'>";
echo " </iframe>";
echo " </div>";
echo " <span class='bottomRight'>";
echo " <p class='label'>".$run['journal'].", ". $run['volume'] .", ". date("F, Y",strtotime($run['publication_date'])) ."@ Pg.". $run['pages'] ."</p>";
echo " </span>";
echo " </span>";
echo " <br style='clear:both;'/>";
echo "</div>";
这里是一些视觉效果