如何找到" a"点击了html元素

时间:2018-06-04 10:12:41

标签: php html

这个php文件找到每个" .html"文件和" .txt"文件并创建一个动态表,其中包含指向另一个页面的链接。在该页面中,我想在框架中显示单击的html文件。

 <html>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <body>

        <?php

        echo '<h2>Escolha o Esquema de MetaDados a utilizar</h2>';
        echo '<table cellspacing="0" cellpadding="0" border="0" class="table">';
        echo '<tr>';
        echo '<th>Esquema de MetaDados</th>';
        echo '<th>Descrição</th>';
        echo '</tr>';

              foreach (glob("Templates/Dinamico/*.html") as $filename) {
              foreach(glob("Templates/Dinamico/*.txt") as $txtname){ 
               $fileH= basename($filename,".html");
               $fileT= basename($txtname,".txt");   
              if($fileH==$fileT){ 
              $txt= file_get_contents ( $txtname); 
            if($filename != "Templates/Dinamico/formD1.html"){ 
                echo'<tr>';
                echo'<td>';
                echo "<a name='".$fileH."'strong href='Templates/Dinamico/formD1.php'>".$fileH."</a>";
                echo'</td>';
                echo'<td>';
                echo $txt;
                echo'</td>';
                echo'</tr>';               
    }
    }
    }
    }
        ?>
    </body>

    </html>

此文件是上面设置的链接页面,单击的元素填充了iframe,其名称分配给&#34; a&#34;元件。

  <html>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <body>
        <div>

        <?php

This $a var i want to be the $fileH clicked on

              echo '<iframe src="' .$a.'" frameBorder="0" width="70%" height="100%" align="left" scrolling="no" />';
              echo '</iframe>'
        ?>
    </div>

    </body>

    </html>

1 个答案:

答案 0 :(得分:1)

您可以将ID作为属性添加到该网址,如下所示:

1528112695159   geckodriver INFO    geckodriver 0.19.1
1528112695168   geckodriver INFO    Listening on 127.0.0.1:3148
1528112747876   mozrunner::runner   INFO    Running command: "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\victorsk\\AppData\\Local\\Temp\\rust_mozprofile.ULuflXGoq9rE"
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\victorsk\AppData\Local\openvr\openvrpaths.vrpath
1528112791808   Marionette  INFO    Listening on port 3158
1528112792599   Marionette  WARN    TLS certificate errors will be ignored for this session
[Parent 36664, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Parent 36664, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 22672, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 22672, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/sr[Parent 36664, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 25068, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 25068, C*** UTM:SVC TimerManager:registerTimer called after profile-before-change notification. Ignoring timer registration for id: telemetry_modules_ping

然后在您的其他页面中,只需获取echo "<a name='".$fileH."'strong href='Templates/Dinamico/formD1.php?id=$fileH'>".$fileH."</a>"; 的ID即可。 在这里找到有关如何传递变量的更多参考。 link1link 2link 3