|
 |
|
Cordova สอบถามครับ การ new page แล้ว กด Backbutton ไม่ให้ page ก่อนหน้า รีโหลดใหม่ |
|
 |
|
|
 |
 |
|
Cordova สอบถามครับ การ new page แล้ว กด Backbutton ไม่ให้ page ก่อนหน้า รีโหลดใหม่
Code
// ไฟล์ ที่ 1 คือ ไฟล์ product.html มีรายการแสดง 100 รายการ คลิก Url new page รายการที่ 50 กลางๆหน้า page ด้วยโค๊ด้านล่างนี้
<a href="view_product.html?PName='+P_Name+'" target="_bank" id="'+P_Name+'"><div class="card" >
//ไฟล์ที่ 2 คือ view_product.html ทำการกด backbutton
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// device APIs are available
//
function onDeviceReady() {
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
document.addEventListener("menubutton", onMenuKeyDown, false);
document.addEventListener('backbutton', function (evt) {
if (cordova.platformId !== 'windows') {
window.history.back();
return;
}
if (window.location.href !== firstPageUrl) {
window.history.back();
} else {
throw new Error('Exit'); // This will suspend the app
}
}, false);
}
พอกดกลับมาแล้ว การโฟกัส กลับไปเริ่มต้น ที่ ด้านบน สุด และ ยังโหลด java script ใหม่อีก พอจะมีแนวทาง ในการ ย้อนกลับ ให้ กลับไปอยู่จุดเดิม เหมือนเปิดผ่านเว็บบราวเซอร์ไหมครับ เปิดแถบใหม่ ปิดไปแถบเดิมก็คงอยู่ที่เดิม ขอบคุณครับ
Tag : Mobile, HTML5, JavaScript, jQuery, iOS, Android

|
|
 |
 |
 |
 |
Date :
2018-09-06 17:03:24 |
By :
Natt |
View :
1215 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าใช้ page1.html และ page2.html พอกดปุ่ม history.back() ก็จะโหลดใหม่อย่างนี้แหล่ะครับเพราะมันอยู่คนล่ะ page กัน ถ้าไม่อยากให้โหลดใหม่ก็ให้อยู่ใน page เดียวกัน และใช้ style sheet มาช่วยในการแสดงผล เช่น
1) <div> ด้านบน/ด้านล่าง
<div id="menu">
<ul>
<li><a href="view_product.html?PName='+P_Name+'" target="content"> Link 1 </a></li>
<li><a href="view_product.html?PName='+P_Name+'" target="content"> Link 2 </a></li>
<li><a href="view_product.html?PName='+P_Name+'" target="content"> Link 3 </a></li>
</ul>
</div>
<div id="content"><iframe name="content" src="about:blank"></iframe></div>
แต่มันกดจะกระโดดไปด้านล่าง
2) หรือใช้ <div> แล้วใช้ style sheet ที่เป็น display และ z-index (รูปแบบ : แสดง/ซ่อน และอยู่ด้านบน/ด้านล่าง แทน)
3) หรือลองศึกษาวิธีของ modal popup แทน
|
 |
 |
 |
 |
Date :
2018-09-08 01:23:47 |
By :
ccjpn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|