使用jQuery mobile庫(kù)檢測(cè)url絕對(duì)地址和相對(duì)地址的方法
path.isAbsoluteUrl() 檢測(cè)絕對(duì)網(wǎng)址
jQuery.mobile.path.isAbsoluteUrl(url)
如果一個(gè)URL是絕對(duì)的實(shí)用方法。如果URL是絕對(duì)的這個(gè)函數(shù)返回一個(gè)布爾值 true ,否則返回 false。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery.mobile.path.isAbsoluteUrl 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/file.html" id="button2" class="myButton" data-inline="true" />
<input type="button" value="/a/file.html" id="button3" class="myButton" data-inline="true" />
<input type="button" value="file.html" id="button4" class="myButton" data-inline="true" />
<input type="button" value="?a=1&b=2" id="button5" class="myButton" data-inline="true" />
<input type="button" value="#foo" id="button6" 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 isAbs = $.mobile.path.isAbsoluteUrl( $( this ).attr( "value" ) );
$( "#myResult" ).html( String( isAbs ) );
})
});
</script>
</body>
</html>
path.isRelativeUrl() 檢查相對(duì)網(wǎng)址
jQuery.mobile.path.isRelativeUrl( url )
如果URL是相對(duì)的網(wǎng)址,這個(gè)函數(shù)返回一個(gè)布爾值 true,否則返回 false。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery.mobile.path.isRelativeUrl 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/file.html" id="button2" class="myButton" data-inline="true" />
<input type="button" value="/a/file.html" id="button3" class="myButton" data-inline="true" />
<input type="button" value="file.html" id="button4" class="myButton" data-inline="true" />
<input type="button" value="?a=1&b=2" id="button5" class="myButton" data-inline="true" />
<input type="button" value="#foo" id="button6" 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 isRel = $.mobile.path.isRelativeUrl( $( this ).attr( "value" ) );
$( "#myResult" ).html( String( isRel ) );
})
});
</script>
</body>
</html>
- jQuery Mobile操作HTML5的常用函數(shù)總結(jié)
- jQuery Mobile 和 Kendo UI 的比較
- jQuery Mobile頁(yè)面返回不需要重新get
- 詳解jQuery Mobile自定義標(biāo)簽
- jQuery mobile 移動(dòng)web(4)
- jquerymobile checkbox及時(shí)刷新才能獲取其準(zhǔn)確值
- jQuery Mobile的loading對(duì)話框顯示/隱藏方法分享
- JqueryMobile動(dòng)態(tài)生成listView并實(shí)現(xiàn)刷新的兩種方法
- 使用jquery mobile做幻燈播放效果實(shí)現(xiàn)步驟
- jQuery Mobile 導(dǎo)航欄代碼
- jQueryMobile之Helloworld與頁(yè)面切換的方法
- jQuery Mobile框架中的表單組件基礎(chǔ)使用教程
相關(guān)文章
jQuery中select與datalist制作下拉菜單時(shí)的區(qū)別淺析
一般我們通常使用select制作下拉菜單,但是H5之后,datalist也可以充當(dāng)select的角色,而且兩者還有一點(diǎn)小的不同。具體區(qū)別詳解小編通過(guò)本文給簡(jiǎn)單介紹下2016-12-12
使用jQuery的attr方法來(lái)修改onclick值
這篇文章主要介紹了通過(guò)jQuery的attr修改onclick值的解決方法 ,需要的朋友可以參考下2014-07-07
jquery隨意添加移除html的實(shí)現(xiàn)代碼
jquery隨意添加移除html的實(shí)現(xiàn)代碼,需要的朋友可以參考下。2011-06-06
jQuery實(shí)現(xiàn)手機(jī)號(hào)碼輸入提示功能實(shí)例
這篇文章主要介紹了jQuery實(shí)現(xiàn)手機(jī)號(hào)碼輸入提示功能,實(shí)例分析了jQuery針對(duì)手機(jī)號(hào)碼的判斷與提示相關(guān)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04
跟著JQuery API學(xué)Jquery 之二 屬性
在選擇器的API學(xué)習(xí)中,走馬觀花的把選擇器過(guò)了一遍,但是選擇歸選擇,選擇出來(lái)了沒(méi)干什么事,也沒(méi)有什么用嘛2010-04-04
基于JQuery的6個(gè)Tab選項(xiàng)卡插件
今天在修整博客側(cè)欄信息時(shí),利用到了Tab選項(xiàng)卡方式,因?yàn)閆Blog封裝的是JQuery庫(kù),所以很自然地就想到了IdTabs。2010-09-09
JQuery實(shí)現(xiàn)動(dòng)態(tài)操作表格
本文主要分享了jQuery實(shí)現(xiàn)對(duì)一個(gè)表格動(dòng)態(tài)的添加行,刪除行,并且對(duì)表格中內(nèi)容進(jìn)行非空驗(yàn)證的示例代碼。具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧2017-01-01
jQuery動(dòng)態(tài)添加 input type=file的實(shí)現(xiàn)代碼
有時(shí)候需要在頁(yè)面上允許用戶上傳多個(gè)文件,個(gè)數(shù)由用戶自己決定,個(gè)數(shù)多了也可以刪除,使用jQuery可以很簡(jiǎn)單的實(shí)現(xiàn)這個(gè)功能2012-06-06

