如何用js得到当前页面的url信息方法(JS获取当前网址信息)

2015-12-8 liyangweb.com 李杨 JavaScript

设置或获取对象指定的文件名或路径。

alert(window.location.pathname)

设置或获取整个 URL 为字符串。

alert(window.location.href);

设置或获取与 URL 关联的端口号码。

alert(window.location.port)

设置或获取 URL 的协议部分。

alert(window.location.protocol)

设置或获取 href 属性中在井号“#”后面的分段。

alert(window.location.hash)

设置或获取 location 或 URL 的 hostname 和 port 号码。

alert(window.location.host)

设置或获取 href 属性中跟在问号后面的部分。

alert(window.location.search)

获取变量的值(截取等号后面的部分)

var url = window.location.search;
var loc = url.substring(url.lastIndexOf('=')+1, url.length);


转自 http://www.cnblogs.com/glj1203/archive/2011/04/07/2008054.html

标签: JavaScript

评论:

cheapcoatsfr
2019-01-18 08:22
<a href="http://www.evolutionecig.com/nike-air-jordan-son-of-mars-true-blu-uniform-scarpec">nike air jordan son of mars true blu uniform</a> <a href="http://www.georginabauer.com/nike-free-3.0-v4-lilla-and-lyser%C3%B8d-hair-kurpesc">nike free 3.0 v4 lilla and lyser酶d hair</a> <a href="http://www.bootsoffprice.com/ray-ban-rb3362-polarized-up-sunglassesg">ray ban rb3362 polarized up</a> <a href="http://www.theprintjobs.com/nike-black-wil-lutz-name-number-logo-nfl-3-new-orleans-saints-long-sleeve-t-shirt-nflr">nike black wil lutz name number logo nfl 3 new orleans saints long sleeve t shirt</a> <a href="http://www.dbajournal.com/adidas-climacool-ride-sky-blue-gold-skoa">adidas climacool ride sky blue gold</a> <a href="http://www.procomedian.com/nike-flyknit-racer-orca-jacks-sneakerf">nike flyknit racer orca jacks</a>
cheapcoatsfr http://www.cheapcoatsfr.com/
praiseti
2019-01-01 05:19
<a href="http://www.atolyekarinca.com/jordan-8-red-zapatosu">jordan 8 red</a> <a href="http://www.dfarrie.com/kobe-11-fundam%C3%A4nnertals-on-feet-chaussuresa">kobe 11 fundam盲nnertals on feet</a> <a href="http://www.mwsuperstore.com/mlb-jerseys-texas-rangers-17-shin-soo-choo-white-jerseys-nflg">mlb jerseys texas rangers 17 shin soo choo white jerseys</a> <a href="http://www.shanamorgan.com/cheap-nike-kobe-5-womens-blue-runningg">cheap nike kobe 5 womens blue</a> <a href="http://www.crisgarrett.com/zdeno-chara-33-boston-bruins-reebok-premier-alternate-jersey-small-nflv">zdeno chara 33 boston bruins reebok premier alternate jersey small</a> <a href="http://www.rejuvmedia.com/nike-lunarglide-6-boy-birthday-trainersa">nike lunarglide 6 boy birthday</a>
praiseti http://www.praiseti.com/
yufnsyb
2018-12-31 01:44
<a href="http://www.daddeaze.com/nike-air-force-1-drake-rt-white-skof">nike air force 1 drake rt white</a> <a href="http://www.debracousins.com/nike-free-nsw-meaning-skob">nike free nsw meaning</a> <a href="http://www.yankaripark.com/black-and-green-fox-racing-hats-for-sale-hatd">black and green fox racing hats for sale</a> <a href="http://www.yicailottery.com/nike-kyrie-2-effect-white-red-multicolor-paint-runninge">nike kyrie 2 effect white red multicolor paint</a> <a href="http://www.calebcraw.com/nike-flyknit-racer-nero-bianca-volt-navigation-schuhea">nike flyknit racer nero bianca volt navigation</a> <a href="http://www.liquidputter.com/nike-lunartempo-schwarz-and-wei%C3%9F-scarpeb">nike lunartempo schwarz and wei脽</a>
[url=http://www.yufnsyb.com/]yufnsyb[/url]
eadscs
2018-12-27 22:12
<a href="http://www.filmkonulari.com/nike-roshe-run-rose-with-une-fleurs-chaussuresg">nike roshe run rose with une fleurs</a> <a href="http://www.fornhamhall.com/nike-roshe-run-rosado-schwarz-chaussuresa">nike roshe run rosado schwarz</a> <a href="http://www.aktiif.com/asics-gel-noosa-tri-9-rojo-gris-butya">asics gel noosa tri 9 rojo gris</a> <a href="http://www.bertankavuncu.com/nike-pegasus-32-arancia-theory-butyd">nike pegasus 32 arancia theory</a> <a href="http://www.budskab.com/adidas-pr%C3%B8dator-remake-2017-atlanta-scarpeg">adidas pr酶dator remake 2017 atlanta</a> <a href="http://www.chocolatecin.com/nike-blazer-rojo-verde-chaussuresb">nike blazer rojo verde</a>
eadscs http://www.eadscs.com/

发表评论:

Powered by emlog 冀ICP备13011830号-1