Re: [請益] 點了超連結後,如何在div裡顯示某網頁檔 …
※ 引述《tkdmaf (皮皮快跑)》之銘言:
: ※ 引述《FacetheFaith ( )》之銘言:
: : 例如有個頁面有這樣一個超連結---> <a href='product.php'>產品編輯</a>
: : 然後這個頁面裡面還有一個 DIV圖層,簡稱div1
: : 想要在點了"產品編輯"後, 在div1裡面show出 product.php的全部內容
: : 不知道該怎麼做比較好??
: : 因為我用innerHTML="product.php", 結果它是顯示"product.php"這樣的字樣
: : 有沒有人知道怎麼弄?? 或是要用iframe??
: <a href="product.php" target="ajai">
: <div id="product"></div>
: <iframe name="ajai" style="display:none"></iframe>
: product.php:
: <?php
: .
: .
: .
: $html = 要輸出的html字串。
: $html = str_replace("\r\n","",$html); //因為innerHTML的字串不能有換行
: $html = str_replace("\"","'",$html); //加上如果是雙引號就會出錯
: ?>
: <script>
: parent.document.getElementById("product").innerHTML = "<?=$html?>";
: </script>
product.php 何不用,省掉 js 字串的問題
<html>
.....meta header....etc.....
<body><?php echo $html; ?></body>
<script type="text/javascript">
parent.document.getElementById("product").innerHTML=document.body.innerHTML;
</script>
</html>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.76.137.169
→
06/21 08:45, , 1F
06/21 08:45, 1F
→
06/21 09:16, , 2F
06/21 09:16, 2F
→
06/21 11:37, , 3F
06/21 11:37, 3F
→
06/21 15:15, , 4F
06/21 15:15, 4F
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章