无法参数化链接并将href提供给上述帧位置

时间:2017-11-23 13:24:14

标签: javascript php html

我想参数化href链接,所以我从PHP循环传递变量。但是当我点击文本时,它没有采用精确的网址,并且显示网址在另一个框架中无效。当我打印参数化链接并存储为document.write()中的链接但不作为href。怎么做到呢?提前致谢

<!DOCTYPE HTML PUBLIC>
<html>
    <head>
    <script language="javascript" type="text/javascript">
    function trial(a,b) {

        var link='http://localhost/DashboardAsPerCustomer/BlackLotus_'+a+'_hello.php';
        //document.write(link);

        parent.table.location.href='link';

    }
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>This is special</title>
    </head>

    <body>
    <p id="demo"></p>
        <?php
        $names=array("Prajna","Vidya","Deepak","Yajana","Mahadev","Latika","Uzma");
        $y=10;

        for($x=0;$x<count($names);$x++)
        {
            echo'<form method="post"><p onClick="trial('.$x.','.$y.');">'.$names[$x].'</p></form><p>';
        }
        ?>
    </body>

</html>

下面的文件是设置4个不同的帧,当onclick发生在上面程序中在php循环中打印的文本时,它调用javascript函数并传递参数,并在第3帧打开特定的参数化链接。

<!DOCTYPE html>
<html>

    <frameset rows="13%,87%,*%">
        <frame src="header.php" scrolling=no >
        <frameset cols="20%,80%,*%" >

          <frame src="phpinsidephp.php" name="tree" >

            <frameset rows="40%,60%,*%">
              <frame src="http://localhost/JqueryAjax/chart4.php" name="table" scrolling=yes >
              <frame src="Tables\project_table.php" name="graph" scrolling=no >  
            </frameset>

        </frameset>
    </frameset>

</html>

1 个答案:

答案 0 :(得分:0)

您必须指定变量link而不是字符串'link'

parent.table.location.href=link;