打开指向不同 iframe 的路径文件


open path files to different iframes

<?php 
// directory path can be either absolute or relative 
$dirPath = "C:/xampp/htdocs/statistics/pdf/"; 
// open the specified directory and check if it's opened successfully 
if ($handle = opendir($dirPath)) { 
   // keep reading the directory entries 'til the end 
   $i=0; 
   while (false !== ($file = readdir($handle))) { 
   $i++; 
      // just skip the reference to current and parent directory 
      if (eregi("'.pdf",$file)){ 
         if (is_dir("$dirPath/$file")) { 
            // found a directory, do something with it? 
            echo "<a href='$dirPath/$file' ><font color='black' link='black' vlink='black' > $file  </font></a><br>"; 
         } else { 
            // found an ordinary file 
            echo "<a href='$dirPath/$file' ><font color='black' link='black' vlink='black' >$i . $file  </font></a><br>"; 
         } 
      } 
   } 
   // ALWAYS remember to close what you opened 
   closedir($handle); 
}  
?>
<iframe src="xxx" width="100%" height="800"style="border: none;"></iframe>

我想打开从我的目录到iframediv的每个不同文件,以隐藏上一个文件并显示按下的链接。这些文件我从我的路径打开它,我想有一个包含这些文件的列表并在 iframe 中打开它。

你想定位iFrames吗?

if (is_dir("$dirPath/$file")) { 
  // found a directory, do something with it? 
  echo "<a href='$dirPath/$file' target='iframe1'><font color='black' link='black' vlink='black' > $file  </font></a><br>"; 
} else { 
  // found an ordinary file 
  echo "<a href='$dirPath/$file' target='iframe2'><font color='black' link='black' vlink='black' >$i . $file  </font></a><br>"; 
} 

<iframe name="iframe1" src="about:blank" width="100%" height="800"style="border: none;"></iframe>
<iframe name="iframe2" src="about:blank" width="100%" height="800"style="border: none;"></iframe>