jQuery mobile轉(zhuǎn)換url地址及獲取url中目錄部分的方法
path.makeUrlAbsolute() 把相對(duì)URL轉(zhuǎn)化為絕對(duì)URL
jQuery.mobile.path.makeUrlAbsolute( relUrl, absUrl )
把相對(duì)URL轉(zhuǎn)化為絕對(duì)URL的方法。這個(gè)函數(shù)返回一個(gè)字符串,絕對(duì)URL。
relUrl:相對(duì)網(wǎng)址。類型:字符串。
absUrl:絕對(duì)網(wǎng)址。類型:字符串。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery.mobile.path.makeUrlAbsolute demo</title>
<link rel="stylesheet" >
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<!-- The script below can be omitted -->
<script src="/resources/turnOffPushState.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
<style>
#myResult{
border: 1px solid;
border-color: #108040;
padding: 10px;
}
</style>
</head>
<body>
<div data-role="page">
<div data-role="content">
<p>The absoulte URL used is http://foo.com/a/b/c/test.html</p>
<input type="button" value="file.html" id="button1" class="myButton" data-inline="true">
<input type="button" value="../../foo/file.html" id="button2" class="myButton" data-inline="true">
<input type="button" value="http://foo.com/bar/file.html" id="button3" class="myButton" data-inline="true">
<input type="button" value="?a=1&b=2" id="button4" class="myButton" data-inline="true">
<input type="button" value="#bar" id="button5" class="myButton" data-inline="true">
<div id="myResult">The result will be displayed here</div>
</div>
</div>
<script>
$(document).ready(function() {
$( ".myButton" ).on( "click", function() {
var absUrl = $.mobile.path.makeUrlAbsolute( $( this ).attr( "value" ), "http://foo.com/a/b/c/test.html" );
$( "#myResult" ).html( absUrl );
})
});
</script>
</body>
</html>
path.get() 確定URL中的目錄部分
jQuery.mobile.path.get( url )
url:只有一個(gè)參數(shù)。類型:字符串。
確定URL中的目錄部分的實(shí)用方法。如果URL沒有斜線,URL的一部分被認(rèn)為是一個(gè)文件。這個(gè)函數(shù)返回一個(gè)給定的URL目錄部分。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery.mobile.path.get demo</title>
<link rel="stylesheet" >
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<!-- The script below can be omitted -->
<script src="/resources/turnOffPushState.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
<style>
#myResult{
border: 1px solid;
border-color: #108040;
padding: 10px;
}
</style>
</head>
<body>
<div data-role="page">
<div data-role="content">
<input type="button" value="http://foo.com/a/file.html" id="button1" class="myButton" data-inline="true" />
<input type="button" value="http://foo.com/a/" id="button2" class="myButton" data-inline="true" />
<input type="button" value="http://foo.com/a" id="button3" class="myButton" data-inline="true" />
<input type="button" value="http://foo.com/a/file.html" id="button4" class="myButton" data-inline="true" />
<input type="button" value="/a/file.html" id="button5" class="myButton" data-inline="true" />
<input type="button" value="file.html" id="button6" class="myButton" data-inline="true" />
<input type="button" value="/file.html" id="button7" class="myButton" data-inline="true" />
<input type="button" value="?a=1&b=2" id="button8" class="myButton" data-inline="true" />
<input type="button" value="#foo" id="button9" class="myButton" data-inline="true" />
<div id="myResult">The result will be displayed here</div>
</div>
</div>
<script>
$(document).ready(function() {
$( ".myButton" ).on( "click", function() {
var dirName = $.mobile.path.get( $( this ).attr( "value" ) );
$( "#myResult" ).html( String( dirName ) );
})
});
</script>
</body>
</html>
- JQuery將文本轉(zhuǎn)化成JSON對(duì)象需要注意的問題
- javascript中html字符串轉(zhuǎn)化為jquery dom對(duì)象的方法
- JQUERY 對(duì)象與DOM對(duì)象之兩者相互間的轉(zhuǎn)換
- jQuery對(duì)象與DOM對(duì)象之間的轉(zhuǎn)換方法
- jQuery如何將選中的對(duì)象轉(zhuǎn)化為原始的DOM對(duì)象
- jQuery對(duì)象和DOM對(duì)象相互轉(zhuǎn)化
- jQuery對(duì)象和DOM對(duì)象的相互轉(zhuǎn)化實(shí)現(xiàn)代碼
- JS對(duì)象轉(zhuǎn)換為Jquery對(duì)象實(shí)現(xiàn)代碼
- 使用jquery獲取url及url參數(shù)的簡(jiǎn)單實(shí)例
- 使用jquery獲取url以及jquery獲取url參數(shù)的實(shí)現(xiàn)方法
- jquery獲取url參數(shù)及url加參數(shù)的方法
- jQuery實(shí)現(xiàn)對(duì)象轉(zhuǎn)為url參數(shù)的方法
相關(guān)文章
通過實(shí)例解析jQ Ajax操作相關(guān)原理
這篇文章主要介紹了通過實(shí)例解析jQ Ajax操作相關(guān)原理,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-09-09
jquery插件開發(fā)之實(shí)現(xiàn)md5插件
這篇文章主要介紹了jquery開發(fā)實(shí)現(xiàn)的md5插件,最后返回的是一串十進(jìn)制數(shù),在jquery1.9.2下測(cè)試通過,需要的朋友可以參考下2014-03-03
Ext.get() 和 Ext.query()組合使用實(shí)現(xiàn)最靈活的取元素方式
想要利用ExtJS的庫函數(shù)對(duì)DOM進(jìn)行各類操作,就要得到Element類型的對(duì)象,但是Ext.get()取到的雖然是Element,但是參數(shù)只能是id,如果大家對(duì)jQuery的selector方式很喜歡和崇拜,那么就一定要學(xué)習(xí)Ext.get()和Ext.query()的組合方式。2011-09-09
輕量級(jí)jQuery插件slideBox實(shí)現(xiàn)帶底欄輪播(焦點(diǎn)圖)代碼
這篇文章主要介紹了輕量級(jí)jQuery插件slideBox實(shí)現(xiàn)帶底欄輪播(焦點(diǎn)圖)代碼,代碼簡(jiǎn)單易懂,非常實(shí)用,特此分享腳本之家平臺(tái)供大家學(xué)習(xí)2016-03-03
jQuery CSS3相結(jié)合實(shí)現(xiàn)時(shí)鐘插件
這篇文章主要介紹了jQuery CSS3相結(jié)合實(shí)現(xiàn)時(shí)鐘插件附源碼下載的相關(guān)資料,需要的朋友可以參考下2016-01-01
jQuery的三種bind/One/Live/On事件綁定使用方法
jQuery是 一款優(yōu)秀的JavaScript框架,在舊版里主要用bind()方法,在新版里又多了兩種One(),Live(),下面介紹這幾種方法的使用2017-02-02
jquery實(shí)現(xiàn)滑動(dòng)樓梯效果
這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)滑動(dòng)樓梯效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09

