drp935159 2015-04-23 00:28
浏览 92

Javascript document.GetElementById('iframe_id')。src ='link'只能工作一次

so here's a very simple question but I'm having difficulties on solving it see i have an iframe and i want to change it's src depending on the link that was clicked

here's the javascript code

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 =  '';
    }

so I used document.getElementById('abstract_frame').src = link; to set the src then on the hideOverlay function I used
document.getElementById('abstract_frame').src = ''; to set the src back to a blank link.

so the problem is when I call on the showOverlay again to set another src link to the iframe with a different value i get a blank screen

here's the 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>";

here's some visuals

enter image description hereenter image description hereenter image description hereenter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序
    • ¥15 多址通信方式的抗噪声性能和系统容量对比
    • ¥15 winform的chart曲线生成时有凸起
    • ¥15 msix packaging tool打包问题
    • ¥15 finalshell节点的搭建代码和那个端口代码教程
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录