spark_wu
javascript获取URL
●asp获取url
方法一:简单,得不到参数,只有一个虚拟路径
geturl =request("url")
方法二:得到整个url,得到参数
\'得到当前页面的地址
function geturl()
on error resume next
dim strtemp
if lcase(request.servervariables("https")) = "off" then
strtemp = "http://"
else
strtemp = "https://"
end if
strtemp = strtemp & request.servervariables("server_name")
if request.servervariables("server_port") <> 80 then strtemp = strtemp & ":" & request.servervariables("server_port")
strtemp = strtemp & request.servervariables("url")
if trim(request.querystring) <> "" then strtemp = strtemp & "?" & trim(request.querystring)
geturl = strtemp
end function
方法三:得到虚拟路径,得到参数
private function geturl()
dim scriptaddress,m_itemurl,m_item
scriptaddress = cstr(request.servervariables("script_name")) \'取得当前地址
m_itemurl = ""
if (request.querystring <> "") then
scriptaddress = scriptaddress & "?"
for each m_item in request.querystring
if m_item = "page_num" then exit for \'此处的作用就是过滤掉page_num这个页次的参数(该参数是在page_turn.asp中自行设置的,根据个人设定而变),否则每次翻页都会叠加这个参数,虽然不影响功能,但总归不太好吧~~
if instr(page,m_item)=0 then
m_itemurl = m_itemurl & m_item &"="& server.urlencode(request.querystring(""&m_item&""))
else
m_itemurl = m_itemurl & m_item &"="& server.urlencode(request.querystring(""&m_item&"")) & "&"
end if
next
else
scriptaddress = scriptaddress & "?"
end if
geturl = scriptaddress & m_itemurl
end function
●●javascript获取url
location.href 返回整个当前url,
若对其赋值:location.href="http://www.sina.com.cn" 则跳转其url
location.host 返回域名和端口号,如:www.sina.com.cn:80
lcation.hostname 返回域名
location.port 返回端口
location.pathname 返回域名后第一个斜框后的字符串
location.hash 跳到本页的某个锚
location.search 取url?后的部分
javascript 的history对象
history.back() 等同于按浏览器的后退按钮
history.forward() 等同于按浏览器的前进按钮
history.current 指当前的url(等同于location.href), 在历史中的索引位置总为 0
history.go(-2)或 history.go("任意.html") 向前或向后移动,或查找字符串标明的最新url

分类:

技术点:

相关文章: