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沒(méi)有斜線,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ì)象需要注意的問(wèn)題
- 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)文章
基于jquery實(shí)現(xiàn)鼠標(biāo)滾輪驅(qū)動(dòng)的圖片切換效果
這篇文章主要介紹了基于jquery實(shí)現(xiàn)鼠標(biāo)滾輪驅(qū)動(dòng)的圖片切換效果,操作簡(jiǎn)單,適合用在產(chǎn)片展示網(wǎng)站中,需要的朋友可以參考下2015-10-10
精選的10款用于構(gòu)建良好易用性網(wǎng)站的jQuery插件
這篇隨筆收集了10款非常給力的jquery 插件,幫助你構(gòu)建易用性良好的網(wǎng)站,希望對(duì)你有用!2011-01-01
JQuery實(shí)現(xiàn)鼠標(biāo)移動(dòng)圖片顯示描述層的方法
這篇文章主要介紹了JQuery實(shí)現(xiàn)鼠標(biāo)移動(dòng)圖片顯示描述層的方法,涉及jQuery鼠標(biāo)事件及動(dòng)畫效果的使用技巧,需要的朋友可以參考下2015-06-06
JQuery.closest(),parent(),parents()尋找父結(jié)點(diǎn)
在50個(gè)必備的實(shí)用jQuery代碼段看到關(guān)于closest()方法的介紹,考慮到開發(fā)過(guò)程中經(jīng)常有找爹的需求,以前用的都是parent()/parents()方法(還經(jīng)常找不到!),所以就此研究對(duì)比一下!2012-02-02
修復(fù)jQuery tablesorter無(wú)法正確排序的bug(加千分位數(shù)字后)
這篇文章主要介紹了如何修復(fù)jQuery tablesorter無(wú)法正確排序的bug(加千分位數(shù)字后)的相關(guān)資料,需要的朋友可以參考下2016-03-03
jQuery實(shí)現(xiàn)仿京東防抖動(dòng)菜單效果示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)仿京東防抖動(dòng)菜單效果,結(jié)合實(shí)例形式分析了jQuery事件響應(yīng)及頁(yè)面屬性動(dòng)態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-07-07

