第一、簡(jiǎn)單介紹一下location屬性、用法以及相 " /> 免费日韩毛片,成人免费视频观看,久久密av

四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

javascript中的location用法簡(jiǎn)單介紹

先前寫了一片用window.location.href實(shí)現(xiàn)刷新另個(gè)框架頁(yè)面 ,特此我看了一下locaiton的詳細(xì)用法,對(duì)此有點(diǎn)改進(jìn),現(xiàn)在我將他整理成js,方便查閱,也貼上和朋友們分享一下,具體如下:

第一、簡(jiǎn)單介紹一下location屬性、用法以及相關(guān)示例:
Location
包含了關(guān)于當(dāng)前 URL 的信息。

描述
location 對(duì)象描述了與一個(gè)給定的 Window 對(duì)象關(guān)聯(lián)的完整 URL。location 對(duì)象的每個(gè)屬性都描述了 URL 的不同特性。
通常情況下,一個(gè) URL 會(huì)有下面的格式:

協(xié)議//主機(jī):端口/路徑名稱#哈希標(biāo)識(shí)?搜索條件 例如:

http://skylaugh.cnblogs.com/index.html#topic1?x=7&y=2 這些部分是滿足下列需求的:

“協(xié)議”是 URL 的起始部分,直到包含到第一個(gè)冒號(hào)。 
“主機(jī)”描述了主機(jī)和域名,或者一個(gè)網(wǎng)絡(luò)主機(jī)的 IP 地址。
“端口”描述了服務(wù)器用于通訊的通訊端口。 
路徑名稱描述了 URL 的路徑方面的信息。
“哈希標(biāo)識(shí)”描述了 URL 中的錨名稱,包括哈希掩碼(#)。此屬性只應(yīng)用于 HTTP 的 URL。 
“搜索條件”描述了該 URL 中的任何查詢信息,包括問號(hào)。此屬性只應(yīng)用于 HTTP 的 URL?!八阉鳁l件”字符串包含變量和值的配對(duì);每對(duì)之間由一個(gè)“&”連接。 

屬性概覽
hash: Specifies an anchor name in the URL. 
host: Specifies the host and domain name, or IP address, of a NETwork host.  
hostname: Specifies the host:port portion of the URL.  
href: Specifies the entire URL.  
pathname: Specifies the URL-path portion of the URL.  
port: Specifies the communications port that the server uses.  
protocol: Specifies the beginning of the URL, including the colon.  
search: Specifies a query. 

方法概覽
reload Forces a reload of the window's current document.  
replace Loads the specified URL over the current history entry.  


主要功能示例,其他類同:
hash:

newWindow.location.href = http://skylaugh.cnblogs.com
newWindow.location.hash = #59831 


host
A string specifying the server name, subdomain, and domain name.
newWindow.location.href =   http://skylaugh.cnblogs.com
newWindow.location.host = skylaugh.cnblogs.com


href
A string specifying the entire URL.

window.location.href="http://home.NETscape.com/"


pathname
A string specifying the URL-path portion of the URL.

search
A string beginning with a question mark that specifies any query information in the URL.

newWindow.location.href = http://skylaugh.cnblogs.com
newWindow.location.search = ?newsid=111 

二、location之頁(yè)面跳轉(zhuǎn)js如下:
//簡(jiǎn)單跳轉(zhuǎn)
function gotoPage(url)
{
// eg. var url = "newsview.html?catalogid="+catalogID+"&pageid="+pageid;
window.location = url;
}
// 對(duì)location用法的升級(jí),為單個(gè)頁(yè)面?zhèn)鬟f參數(shù)
function goto_catalog(iCat)
{
if(iCat<=0)
{
top.location = "../index.ASPx"; // top出去
}
else
{
window.location = "../newsCat.ASPx?catid="+iCat;
}
}
// 對(duì)指定框架進(jìn)行跳轉(zhuǎn)頁(yè)面,二種方法皆可用
function goto_iframe(url)
{
parent.mainFrame.location = "../index.ASPx"; //
// parent.document.getElementById("mainFrame").src = "../index.ASPx";// use dom to change page // 同時(shí)我增加了dom的寫法
}
// 對(duì)指定框架進(jìn)行跳轉(zhuǎn)頁(yè)面,因?yàn)?nbsp;parent.iframename.location="../index.ASPx"; 方法不能實(shí)行,主要是 "parent.iframename" 中的iframename在js中被默認(rèn)為節(jié)點(diǎn),而不能把傳遞過來的參數(shù)轉(zhuǎn)換過來,所以用dom實(shí)現(xiàn)了該傳遞二個(gè)參數(shù)的框架跳轉(zhuǎn)頁(yè)面,希望那位仁兄不吝賜教!
function goto_iframe(iframename,url) 
{
parent.document.getElementById(iframename).src = "../index.ASPx";// use dom to change page by iframeName

//}
// 回到首頁(yè)
function gohome()
{
top.location = "/index.ASPx";
}
</script>

JavaScript技術(shù)javascript中的location用法簡(jiǎn)單介紹,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 色戒在线观看视频| 日韩 欧美 视频| 长靴靴虐视频vk| 转转二手手机| 时来运转电影| 都市频道节目表今天| 笔仙2大尺度床戏| 隐藏的真相| 小牛加速器安卓版| 印度超人3| 浙江卫视回放观看入口| 五年级上册书法教案| 日本大电影| 又大又肥又圆的白屁股| wall.e| 边缘战士| 长靴靴虐视频vk| 妇女停经前有什么征兆| 胡克·霍根| 韧战作文600字| 双罗衫简谱| 乔什布洛林| 恶行之外电影完整在线观看| 午间电影| 不要好舒服| 郑俊河| 礼运节选高中原文| 改病句| 余娅| 少女第一季| 初一英语完形填空20篇免费| 男按摩师给女性做私密按摩| 护航 电影| 天地姻缘七仙女演员表| 红色角落| 刘禹| 康熙王朝电视剧多少集| 在线观看亚| porn21| 土壤动植物的乐园教学反思| 在线免费电影网站|