# ช่วยแก้ script สั้นๆ กำลังจะดึงหน้า page มาแสดงอีกหน้า ทำไม่ได้สักที ช่วยทีคับ

เริ่มโดย น้องบิ้ว, 13 ตุลาคม 2013, 20:14:30

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

น้องบิ้ว

ดีคับ คือผมทำหน้า  content.php , content.html ไว้ ในนั้นมีเนื้อหาธรรมดาแต่มันยาวมาก
แล้วผมสร้างหน้า info.php  แล้วอยากจะดึงหน้าหน้า content.php , content.html มาแสดงผลในหน้านี้ info.php ตรงตำแหน่งที่ผมต้องการ ใช้คำสั่งนี้  แต่ว่ามันไม่มาขึ้น warning

     <?php
$homepage = file_get_contents('content.php');
echo $homepage;
?>

คือจิงๆผมใช้ iframe ก็ได้ เพียงแต่ว่า iframe มันจะมี scroll bar แสดงออกมา คือหน้านั้นมันยาว อยากให้หน้า page มันเลื่อนตามหน้าหลักนะคับ ไม่อยากให้มันมี scroll bar ใน iframe ผมเลยคิดว่ามันน่าจะมี php ดึงหน้านั้นมาแสดงผลได้เลยนะคับ  มีท่านใดแนะนำได้บ้างไหมคับ   :wanwan017:

gubaaball

มันขึ้น warning อะไรครับ ผมว่าพาธ content.php มันไม่ถูกหรือเปล่าครับ หรือไม่งั้นลองดูลิงค์นี้น่ะครับอาจจะช่วยได้

http://www.thaicreate.com/php/forum/036031.html

น้องบิ้ว

อ้างถึงจาก: gubaaball ใน 13 ตุลาคม 2013, 20:23:57
มันขึ้น warning อะไรครับ ผมว่าพาธ content.php มันไม่ถูกหรือเปล่าครับ หรือไม่งั้นลองดูลิงค์นี้น่ะครับอาจจะช่วยได้

http://www.thaicreate.com/php/forum/036031.html

มันขึ้นงี้คับ

Warning: file_get_contents(http://www.domain.comcontent.php) [function.file-get-contents]: failed to open stream: HTTP request failed! in /home/xxx/domains/xxx.com/public_html/info.php on line 91

เด๋วขออ่านกระทู้นั้นก่อนนะคับ

ลองตะกี้คับในกระทู้ลองทำตาม erro เหมือนกันเลยคับ

หรือมีคำสั่งอื่นจะเปน java jquery ก็ได้คับ  แค่ไม่เอา iframe นะคับ

afterdead

ขายเว็บอ่านการ์ตูน Manga Traffic 4000+/days PageView 36,000/ days PM
VPS CHEAP
[direct=https://www.digitalocean.com/?refcode=66904e5523f1]สุดยอด ! CLOUD VPS SSD 20 GB RAM 512 จ่ายผ่าน Paypal หรือ บัตรเครดิต ! แค่ $5.0 คุ้มกว่านี้มีที่ไหน มีสิงค์โปร์ ใช้กับเว็บไทยสุดยอดขอบอกๆ[/direct]
Unlimited & Unlimited Hosting.
HOST GATOR COUPONS ลด 25% ใส่คูปอง "tsbgator25off" [direct=https://signup.hostgator.com/hg4/shared-29-36-tsbgator25off?]>>>Hatchling Plan<<<[/direct] |

bestnmk21

:)

น้องบิ้ว

อ้างถึงจาก: bestnmk21 ใน 13 ตุลาคม 2013, 20:39:09
@include('content.php');

แบบนี้ได้ไหม

ขอบคุณมากคับ ได้แล้วคับ ใช้ @include คับ
ขอบคุนทุกท่านเหมือนกันคับ

น้องบิ้ว

เจอวิธีใหม่ง่ายกว่าเดิม คือใช้ iframe อีกแบบนึง คือปกติเราใช้ iframe หน้าที่ดึงมามันจะยาวไม่เท่ากันทำให้ต้องกำหนดความสูงและมี scorller bar  แต่โค้ดนี้จะทำให้ความยาวของหน้ามันจะ ยาวตามหน้าที่ดึงมา แบบไม่ต้องมี scoller bar คับ คือยาวอัตโนมัตตามหน้าที่ดึงมา

ใส่นี่ลงส่วน head

<script type='text/javascript'>

function setIframeHeight( iframeId ) /** IMPORTANT: All framed documents *must* have a DOCTYPE applied **/
{
var ifDoc, ifRef = document.getElementById( iframeId );

try
{   
  ifDoc = ifRef.contentWindow.document.documentElement; 
}
catch( e )
{
  try
  {
   ifDoc = ifRef.contentDocument.documentElement; 
  }
  catch(ee)
  {   
  } 
}

if( ifDoc )
{
  ifRef.height = 1; 
  ifRef.height = ifDoc.scrollHeight;
 
  /* For width resize, enable below.  */
 
  // ifRef.width = 1;
  // ifRef.width = ifDoc.scrollWidth;
}
}

</script>

ใส่นี่ตรงส่วน body

<iframe id = "myIframe"  onload = "setIframeHeight( this.id )" width="850" height="100%" scrolling="no" src="yourcontent.html" frameborder="0" >
</iframe>


pook

อ้างถึงจาก: น้องบิ้ว ใน 13 ตุลาคม 2013, 21:43:37
เจอวิธีใหม่ง่ายกว่าเดิม คือใช้ iframe อีกแบบนึง คือปกติเราใช้ iframe หน้าที่ดึงมามันจะยาวไม่เท่ากันทำให้ต้องกำหนดความสูงและมี scorller bar  แต่โค้ดนี้จะทำให้ความยาวของหน้ามันจะ ยาวตามหน้าที่ดึงมา แบบไม่ต้องมี scoller bar คับ คือยาวอัตโนมัตตามหน้าที่ดึงมา

ใส่นี่ลงส่วน head

<script type='text/javascript'>

function setIframeHeight( iframeId ) /** IMPORTANT: All framed documents *must* have a DOCTYPE applied **/
{
var ifDoc, ifRef = document.getElementById( iframeId );

try
{   
  ifDoc = ifRef.contentWindow.document.documentElement; 
}
catch( e )
{
  try
  {
   ifDoc = ifRef.contentDocument.documentElement; 
  }
  catch(ee)
  {   
  } 
}

if( ifDoc )
{
  ifRef.height = 1; 
  ifRef.height = ifDoc.scrollHeight;
 
  /* For width resize, enable below.  */
 
  // ifRef.width = 1;
  // ifRef.width = ifDoc.scrollWidth;
}
}

</script>

ใส่นี่ตรงส่วน body

<iframe id = "myIframe"  onload = "setIframeHeight( this.id )" width="850" height="100%" scrolling="no" src="yourcontent.html" frameborder="0" >
</iframe>


อันนี้เจ๋งครับ :D