发布:2023/1/5 17:08:52作者:管理员 来源:本站 浏览次数:556
1、通过C#获取当前页面的URL
复制代码 代码如下:
string url = Request.Url.AbsoluteUri; //结果: http://www.ejk5.com/news/show-3257.html
string host = Request.Url.Host; //结果:www.ejk5.com
string rawUrl = Request.RawUrl; //结果:/news/show-3257.html
string localPath = Request.Url.LocalPath; //结果:/news/show-3257.html
2、通过Javascript获取当前页面的URL
复制代码 代码如下:
var url = document.URL; //结果:http://www.ejk5.com/news/show-3257.html
var href = document.location.href; //结果:http://www.ejk5.com/news/show-3257.html
var host = location.hostname; //结果:www.ejk5.com
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4