把一个相对的文件或目录路径转化为绝对路径。
具有两个参数 relPath (string, 必须) 和 absPath (string, 必须) ,具体如下:
(1)—— relPath (string, 必须)
其值为一个相对的文件或目录路径。
(2)—— absPath (string, 必须)
用于解析的一个绝对的文件或相对的路径。
$.mobile.path.makePathAbsolute() 会返回一个包含相对路径的绝对路径版本的字符串。
例子:
// 返回: /a/b/c/file.html
var absPath = $.mobile.path.makePathAbsolute("file.html", "/a/b/c/bar.html");// 返回: /a/foo/file.html
var absPath = $.mobile.path.makePathAbsolute("../../foo/file.html", "/a/b/c/bar.html");
十二. $.mobile.path.makeUrlAbsolute()
把一个相对 URL 转化为绝对 URL 。
具有两个参数 relUrl (string, 必选) 和 absUrl (string, 必选) ,具体如下:
—— relUrl (string, 必选)
一个相对形式的 URL 。
—— absUrl (string, 必选)
用于解析的一个绝对的文件或相对的路径。
$.mobile.path.makeUrlAbsolute() 会返回一个包含相对 URL 的绝对 URL 版本的字符串。
例子:
// 返回: http://foo.com/a/b/c/file.html
var absUrl = $.mobile.path.makeUrlAbsolute("file.html", "http://foo.com/a/b/c/test.html");// 返回: http://foo.com/a/foo/file.html
var absUrl = $.mobile.path.makeUrlAbsolute("../../foo/file.html", "http://foo.com/a/b/c/test.html");
// 返回: http://foo.com/bar/file.html
var absUrl = $.mobile.path.makeUrlAbsolute("//foo.com/bar/file.html", "http://foo.com/a/b/c/test.html");
// 返回: http://foo.com/a/b/c/test.html?a=1&b=2
var absUrl = $.mobile.path.makeUrlAbsolute("?a=1&b=2", "http://foo.com/a/b/c/test.html");
// 返回: http://foo.com/a/b/c/test.html#bar
var absUrl = $.mobile.path.makeUrlAbsolute("#bar", "http://foo.com/a/b/c/test.html");
十三. $.mobile.path.isSameDomain()
比较两个 URL 的域。
具有两个参数 url1 (string, 可选) 和 url2 (string, 可选) 具体情况如下:
—— url1 (string, 可选)
一个相对 URL。
—— url2 (string, 可选)
url2 (string, required) 一个需要解析的绝对 URL 。
返回值为 boolean 型变量,若两个域匹配,则返回 “true” ,否则返回 “false” 。
例子:
// 返回: true
var same = $.mobile.path.isSameDomain("http://foo.com/a/file.html", "http://foo.com/a/b/c/test.html");// 返回: false
var same = $.mobile.path.isSameDomain("file://foo.com/a/file.html", "http://foo.com/a/b/c/test.html");
// 返回: false
var same = $.mobile.path.isSameDomain("https://foo.com/a/file.html", "http://foo.com/a/b/c/test.html");










