永发信息网

C#或js如何获取域名?

答案:5  悬赏:60  手机版
解决时间 2021-05-16 01:48

C#或js如何获取域名?

高手进。

最佳答案
你可以通过 url来获得IP 和 域名的 注意看下绝对路径
全部回答

javascript 获取域名

<script language="javascript"> //获取域名 host = window.location.host; host2=document.domain; //获取页面完整地址 url = window.location.href; document.write("<br>host="+host) document.write("<br>host2="+host2) document.write("<br>url="+url) </script>

C#根据网址获取域名

public string GetUrlDomainName(string strHtmlPagePath) { string p = @"http://[^\.]*\.(?<domain>[^/]*)"; Regex reg = new Regex(p,RegexOptions.IgnoreCase); Match m = reg.Match(strHtmlPagePath); return m.Groups["domain"].Value; }

非原创 测试有效 <table width=100% cellpadding=0 cellspacing=0 border=0 > <script> thisURL = document.URL; thisHREF = document.location.href; thisSLoc = self.location.href; thisDLoc = document.location; strwrite = "<tr><td valign=top>thisURL: </td><td>[" + thisURL + "]</td></tr>" strwrite += "<tr><td valign=top>thisHREF: </td><td>[" + thisHREF + "]</td></tr>" strwrite += "<tr><td valign=top>thisSLoc: </td><td>[" + thisSLoc + "]</td></tr>" strwrite += "<tr><td valign=top>thisDLoc: </td><td>[" + thisDLoc + "]</td></tr>" document.write( strwrite ); </script> thisDLoc = document.location; <BR> thisURL = document.URL; <BR> thisHREF = document.location.href; <BR> thisSLoc = self.location.href;<BR> <script> thisTLoc = top.location.href; thisPLoc = parent.document.location; thisTHost = top.location.hostname; thisHost = location.hostname; strwrite = "<tr><td valign=top>thisTLoc: </td><td>[" + thisTLoc + "]</td></tr>" strwrite += "<tr><td valign=top>thisPLoc: </td><td>[" + thisPLoc + "]</td></tr>" strwrite += "<tr><td valign=top>thisTHost: </td><td>[" + thisTHost + "]</td></tr>" strwrite += "<tr><td valign=top>thisHost: </td><td>[" + thisHost + "]</td></tr>" document.write( strwrite ); </script> thisTLoc = top.location.href; <BR> thisPLoc = parent.document.location; <BR> thisTHost = top.location.hostname; <BR> thisHost = location.hostname;<BR> <script> tmpHPage = thisHREF.split( "/" ); thisHPage = tmpHPage[ tmpHPage.length-1 ]; tmpUPage = thisURL.split( "/" ); thisUPage = tmpUPage[ tmpUPage.length-1 ]; strwrite = "<tr><td valign=top>thisHPage: </td><td>[" + thisHPage + "]</td></tr>" strwrite += "<tr><td valign=top>thisUPage: </td><td>[" + thisUPage + "]</td></tr>" document.write( strwrite ); </script><tr><td>
c# Server.MapPath()
request.servervariables("HTTP_REFERER")
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
幸福是什么样的旋律? 爱能经的起考验吗?
资阳区益阳资阳区书法家协会我想知道这个在什
面色如常是什么意思,男主是冥王女主叫什么忘
为什么麻将是四个人打的
如何做一个快乐的人?
人生的成功是什么过程
禹州市许昌好日子美食(冰河路店)怎么去啊,谁
账户名怎么填写,银行账号名称和银行账户名称
女生的聊天主题是什么话题
汽修这门专业的前景好吗?
哇呜。。为什么有的人那么喜欢骂人!!!
请问天翼189的卡号多少钱一张啊
半夜三更是什么时候,二更是几点
樊城区襄樊康美家地址在哪,我要去那里
星期了,做什么好?
推荐资讯
天灰这首歌的MV讲述的是什么样的故事?
什么情况会导致经期延迟
请问从三门峡到喉马凌晨3点有没有汽车
向阳区佳木斯中国建设银行(友谊路支行)在哪里
诛仙仙府角色怎么激活?
成熟稳重儒雅诗词,表达沉稳的诗句
侠盗猎车5穿蓝色衣的人物有飞机密集吗
上蔡县驻马店皇嘉婚庆会所怎么去啊,谁知道地
缘灭长安电子书下载
<三国》的读书笔记,要一百字以上
关于人生唯美的段落,飘摇人生中段家公子为什
最近有那些新歌好听呢?你有多少?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?