如何通过点击网址打开iframe

时间:2014-02-28 03:52:06

标签: javascript php

我需要点击ahref打开iframe窗口。这是我的代码,我需要打开ahref作为iframe的链接。

有人可以帮我这么做吗?

代码:

function selectRepair()
    {
          $this->content_jscript = <<<End_Of_String

End_Of_String;


        $data = graphsCreationSQL::getRepairList ();
        $reapirList = "";
        foreach ( $data as $row )
        {
            $reapirList .= "<a href='create-graphs-repair.php?{$this->htmlID_type}={$this->type_generategraphs}&{$this->htmlID_reapirName}=$row->clientName'>$row->clientName</a></br>";
        }


        $this->content_html = <<<End_Of_String

                            {$reapirList}

End_Of_String;
    }

1 个答案:

答案 0 :(得分:1)

不是100%确定这是否可以从通过网址的角度来看,我的基本javascript有点生疏,尽管你应该能够找到一些与之相关的东西。

foreach ( $data as $row )
{
    $repairList .= "<a href=\"#\" onclick=\"makeIFrame('create-graphs-repair.php?{$this->htmlID_type}={$this->type_generategraphs}&{$this->htmlID_reapirName'}=$row->clientName)\">$row->clientName</a>"
}

然后在Javascript中

function makeIFrame(url) { 
    iframe = document.createElement("iframe"); 
    iframe.setAttribute("src", url); 
    iframe.style.width = 640+"px"; 
    iframe.style.height = 480+"px"; 
    document.body.appendChild(iframe); 
}