使用jQuery mobile庫檢測url絕對(duì)地址和相對(duì)地址的方法
path.isAbsoluteUrl() 檢測絕對(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頁面返回不需要重新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與頁面切換的方法
- jQuery Mobile框架中的表單組件基礎(chǔ)使用教程
相關(guān)文章
jQuery 類twitter的文本字?jǐn)?shù)限制帶提示效果插件
基于jquery的仿twitter的文本字?jǐn)?shù)限制帶提示效果插件,這里提示比較好,不是簡單的限制,給用戶更好的體驗(yàn)。2010-04-04基于jQuery實(shí)現(xiàn)的水平和垂直居中的div窗口
在建立網(wǎng)頁布局的時(shí)候,我們經(jīng)常會(huì)面臨一個(gè)問題,就是讓一個(gè)div實(shí)現(xiàn)水平和垂直居中,雖然好幾種方式實(shí)現(xiàn),但是今天介紹時(shí)我最喜歡的方法,通過css和jQuery實(shí)現(xiàn)。2011-08-08jQuery點(diǎn)擊按鈕彈出遮罩層且內(nèi)容居中特效
這篇文章主要介紹了jQuery點(diǎn)擊按鈕彈出遮罩層且內(nèi)容居中特效,需要的朋友可以參考下2015-12-12輕松使用jQuery雙向select控件Bootstrap Dual Listbox
這篇文章主要教大家如何輕松使用jQuery雙向select控件Bootstrap Dual Listbox,感興趣的小伙伴們可以參考一下2015-12-12jquery實(shí)現(xiàn)簡單的拖拽效果實(shí)例兼容所有主流瀏覽器
拖拽效果個(gè)人覺得是一種不錯(cuò)的用戶體驗(yàn),抽空研究了一下,原理還蠻簡單的,具體實(shí)現(xiàn)如下,感興趣的朋友可以參考下哈2013-06-06jQuery的時(shí)間datetime控件在AngularJs中的使用實(shí)例(分享)
下面小編就為大家?guī)硪黄猨Query的時(shí)間datetime控件在AngularJs中的使用實(shí)例(分享)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-08-08jquery構(gòu)造器的實(shí)現(xiàn)代碼小結(jié)
jQuery的$符號(hào)非常神奇,它可以接受一個(gè)字符,也可以接受一個(gè)文檔對(duì)象或window對(duì)象,亦可以傳個(gè)函數(shù)進(jìn)行變?yōu)閐omReady加載器2011-05-05jQuery中使用validate插件校驗(yàn)表單功能
這篇文章主要介紹了jQuery中使用validate插件校驗(yàn)表單功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒,需要的朋友可以參考下2019-05-05