CSMJU jQuery Mobile

เมนู
ถัดไป ก่อนหน้า

4.3 Methods & Utilities

$.mobile.path.isSameDomain()

   ประโยชน์เมธอดนี้สำหรับเปรียบเทียบโดเมนของ 2 URL

อากิวเมนต์:

   url1 (string, required) ความสัมพันธ์ URL

   url2 (string, required) แก้ปัญหา URL ให้สมบูรณ์

การส่งค่ากลับ

   ฟังก์ชั่นนี้จะส่งค่า boolean ที่เป็น true กลับ ถ้าเหมาะสมกับโดเมนหากเป็น false จะไม่ดำเนินการใดๆ

ตัวอย่าง


// Returns: true
var same = $.mobile.path.isSameDomain("http://foo.com/a/file.html", "http://foo.com/a/b/c/test.html");
// Returns: false
var same = $.mobile.path.isSameDomain("file://foo.com/a/file.html", "http://foo.com/a/b/c/test.html");
// Returns: false
var same = $.mobile.path.isSameDomain("https://foo.com/a/file.html", "http://foo.com/a/b/c/test.html");
// Returns: false
var same = $.mobile.path.isSameDomain("http://foo.com/a/file.html", "http://bar.com/a/b/c/test.html");

$.mobile.path.isRelativeUrl()

   ประโยชน์เมธอดนี้สำหรับการกำหนดว่า URL เป็นความสัมพันธ์กับตัวแปล

อากิวเมนต์

   url (string, required) URL แบบความสัมพันธ์ หรือ URL แบบสมบูรณ์

การส่งค่ากลับ

ฟังก์ชั่นนี้จะส่งค่า boolean ที่เป็น true กลับ หากเป็น URL แบบความสัมพันธ์หากเป็น false จะไม่ดำเนินการใดๆ

ตัวอย่าง


// Returns: false
var isRel = $.mobile.path.isRelativeUrl("http://foo.com/a/file.html");
// Returns: true
var isRel = $.mobile.path.isRelativeUrl("//foo.com/a/file.html");
// Returns: true
var isRel = $.mobile.path.isRelativeUrl("/a/file.html");
// Returns: true
var isRel = $.mobile.path.isRelativeUrl("file.html");
// Returns: true
var isRel = $.mobile.path.isRelativeUrl("?a=1&b=2");
// Returns: true
var isRel = $.mobile.path.isRelativeUrl("#foo");

$.mobile.path.isAbsoluteUrl()

   ประโยชน์เมธอดนี้สำหรับการกำหนดว่าเป็น URL แบบสมบูรณ์

อากิวเมนต์

   url (string, required) URL แบบความสัมพันธ์ หรือ URL แบบสมบูรณ์

การส่งค่ากลับ

   ฟังก์ชั่นนี้จะส่งค่า boolean ที่เป็น true กลับถ้า URL เป็บแบบสมบูรณ์หากเป็น false จะไม่ดำเนินการใดๆ

ตัวอย่าง


// Returns: true
var isAbs = $.mobile.path.isAbsoluteUrl("http://foo.com/a/file.html");
// Returns: false
var isAbs = $.mobile.path.isAbsoluteUrl("//foo.com/a/file.html");
// Returns: false
var isAbs = $.mobile.path.isAbsoluteUrl("/a/file.html");
// Returns: false
var isAbs = $.mobile.path.isAbsoluteUrl("file.html");
// Returns: false
var isAbs = $.mobile.path.isAbsoluteUrl("?a=1&b=2");
// Returns: false
var isAbs = $.mobile.path.isAbsoluteUrl("#foo");

$.mobile.path.get()

   ประโยชน์เมธอดสำหรับกำหนดส่วนไดเรกเทอรีของ URL ถ้า URL ไม่มี slash ของส่วนท้าย URL ถือว่าเป็นไฟล์

อากิวเมนต์

   url (string, required) URL แบบความสัมพันธ์ หรือ URL แบบสมบูรณ์

การส่งค่ากลับ

   ฟังก์ชั่นนี้จะส่งกลับส่วนไดเรกทอรีของ URL ที่กำหนด

ตัวอย่าง

ฟังก์ชั่นนี้จะส่งกลับส่วนไดเรกทอรีของ URL ที่กำหนด


// Returns: http://foo.com/a/
var dirName = $.mobile.path.get("http://foo.com/a/file.html");
// Returns: http://foo.com/a/
var dirName = $.mobile.path.get("http://foo.com/a/");
// Returns: http://foo.com/a
var dirName = $.mobile.path.get("http://foo.com/a");
// Returns: //foo.com/a/
var dirName = $.mobile.path.get("//foo.com/a/file.html");
// Returns: /a/
var dirName = $.mobile.path.get("/a/file.html");
// Returns: ""
var dirName = $.mobile.path.get("file.html");
// Returns: /
var dirName = $.mobile.path.get("/file.html");
// Returns: ?a=1&b=2
var dirName = $.mobile.path.get("?a=1&b=2");
// Returns: foo
var dirName = $.mobile.path.isAbsoluteUrl("#foo");

$.mobile.base

   ประโยชน์สำหรับการทำงานร่วมกับการสร้างองค์ประกอบพื้นฐาน

สิ่งที่ต้องทำ:document ทั่วไปสรุปเป็น API

$.mobile.silentScroll()

   เลื่อนไปเฉพาะตำแหน่ง Y โดยจะไม่เรียกเหตุการณ์ของการเลื่อน

อากิวเมนต์

   yPos (number, ค่าปกติเป็น 0)

ผ่านหมายเลขใด ๆ ที่เลื่อนไปยังตำแหน่งที่ Y

ตัวอย่าง


//scroll to Y 100px
$.mobile.silentScroll(100);

$.mobile.activePage อ้างอิงถึงในมุมมองหน้าเพจปัจจุบัน