<meta charset="utf8"> <!DOCTYPE html> <html> <body> <h2>เปลี่ยนหน้าโดยไม่ รีเฟรช</h2> <button type="button" onclick="loadDoc()">home</button> <button type="button" onclick="loadDoc1()">page1</button> <button type="button" onclick="loadDoc2()">page2</button> <p id="demo">ข้อมูลตรงนี้จะถูกแทนที่ด้วย การดึงหน้า page อื่นๆ เข้ามา</p> <script> function loadDoc() { var xhttp; if (window.XMLHttpRequest) { xhttp = new XMLHttpRequest(); } else { xhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("demo").innerHTML = this.responseText; } }; //ไปสร้างหน้าเพิ่มเติม ใน folder ของเรา xhttp.open("GET", "home.php", true); xhttp.send(); } function loadDoc1() { var xhttp; if (window.XMLHttpRequest) { xhttp = new XMLHttpRequest(); } else { xhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("demo").innerHTML = this.responseText; } }; //ไปสร้างหน้าเพิ่มเติม ใน folder ของเรา xhttp.open("GET", "page1.php", true); xhttp.send(); } function loadDoc2() { var xhttp; if (window.XMLHttpRequest) { xhttp = new XMLHttpRequest(); } else { xhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("demo").innerHTML = this.responseText; } }; //ไปสร้างหน้าเพิ่มเติม ใน folder ของเรา xhttp.open("GET", "page2.php", true); xhttp.send(); } </script> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง