欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery mobile轉(zhuǎn)換url地址及獲取url中目錄部分的方法

 更新時(shí)間:2015年12月04日 15:02:34   投稿:goldensun  
這篇文章主要介紹了jQuery mobile轉(zhuǎn)換url地址及獲取url中目錄部分的方法,轉(zhuǎn)換url地址本文中介紹的是將相對(duì)url轉(zhuǎn)化為絕對(duì)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>

相關(guān)文章

  • 圖標(biāo)線性回歸斜著移動(dòng)到指定的位置

    圖標(biāo)線性回歸斜著移動(dòng)到指定的位置

    圖標(biāo)斜著移動(dòng)到指定的位置如何實(shí)現(xiàn),本文給予了詳細(xì)的解決方法,感興趣的朋友可以參考下,希望對(duì)大家有所幫助
    2013-08-08
  • 通過實(shí)例解析jQ Ajax操作相關(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插件

    這篇文章主要介紹了jquery開發(fā)實(shí)現(xiàn)的md5插件,最后返回的是一串十進(jìn)制數(shù),在jquery1.9.2下測試通過,需要的朋友可以參考下
    2014-03-03
  • jQuery實(shí)現(xiàn)的放大鏡效果示例

    jQuery實(shí)現(xiàn)的放大鏡效果示例

    這篇文章主要介紹了jQuery實(shí)現(xiàn)的放大鏡效果,結(jié)合實(shí)例形式分析了jQuery插件zoom.js實(shí)現(xiàn)放大鏡功能的相關(guān)操作技巧,需要的朋友可以參考下
    2016-09-09
  • Ext.get() 和 Ext.query()組合使用實(shí)現(xiàn)最靈活的取元素方式

    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
  • jquery 使用簡明教程

    jquery 使用簡明教程

    jQuery是目前使用最廣泛的javascript函數(shù)庫。據(jù)統(tǒng)計(jì),全世界排名前100萬的網(wǎng)站,有46%使用jQuery,遠(yuǎn)遠(yuǎn)超過其他庫。微軟公司甚至把jQuery作為他們的官方庫。對(duì)于網(wǎng)頁開發(fā)者來說,學(xué)會(huì)jQuery是必要的。因?yàn)樗屇懔私鈽I(yè)界最通用的技術(shù),為將來學(xué)習(xí)更高級(jí)的庫打下基礎(chǔ),并且確實(shí)可以很輕松地做出許多復(fù)雜的效果
    2014-03-03
  • 輕量級(jí)jQuery插件slideBox實(shí)現(xiàn)帶底欄輪播(焦點(diǎn)圖)代碼

    輕量級(jí)jQuery插件slideBox實(shí)現(xiàn)帶底欄輪播(焦點(diǎn)圖)代碼

    這篇文章主要介紹了輕量級(jí)jQuery插件slideBox實(shí)現(xiàn)帶底欄輪播(焦點(diǎn)圖)代碼,代碼簡單易懂,非常實(shí)用,特此分享腳本之家平臺(tái)供大家學(xué)習(xí)
    2016-03-03
  • jQuery CSS3相結(jié)合實(shí)現(xiàn)時(shí)鐘插件

    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的三種bind/One/Live/On事件綁定使用方法

    jQuery是 一款優(yōu)秀的JavaScript框架,在舊版里主要用bind()方法,在新版里又多了兩種One(),Live(),下面介紹這幾種方法的使用
    2017-02-02
  • jquery實(shí)現(xiàn)滑動(dòng)樓梯效果

    jquery實(shí)現(xiàn)滑動(dòng)樓梯效果

    這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)滑動(dòng)樓梯效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09

最新評(píng)論