求:JS获取当前URL并替换前面、然后输出【或者只获取.com后面的URL】

meng014131 2015-11-27 06:07:06
最好是只获取后面的一段

如 bbs.csdn.net/378244.html

之获取 368244.html

像这种只能在PHP页面才生效,

<meta http-equiv="mobile-agent" content="format=xhtml;url=http://m.csdn.com{eval echo $_SERVER['REQUEST_URI'];}">

我网站文件都有事html的页面,所以求JS的代码 3Q
...全文
545 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
meng014131 2015-12-21
  • 打赏
  • 举报
回复
看来JS是起不了作用的,html网站模板只好调用官网的变量代码了来实现了,比如织梦程序,掉用当前帖子ID、栏目ID http://m.bbs.csdn.net/帖子变量代码.html .... 然后一一去改对应模板【头部】 供和我一样的菜鸟参考
slwsss 2015-11-29
  • 打赏
  • 举报
回复
这东西用js起不了作用的
meng014131 2015-11-29
  • 打赏
  • 举报
回复
<meta http-equiv="mobile-agent" content="format=html5; url=http://32874.com/{后面是代码}"> <meta http-equiv="mobile-agent" content="format=xhtml; url=http://32874.com//{后面是代码}"> PHP代码有,但html页面不起作用,求JS的
meng014131 2015-11-29
  • 打赏
  • 举报
回复
引用 8 楼 KK3K2005 的回复:
[quote=引用 7 楼 meng014131 的回复:] [quote=引用 6 楼 KK3K2005 的回复:] 真作孽 <head> <script type="text/javascript"> document.write(location.pathname); </script> </head>
大神啊,我试过了啊,不起作用[/quote] 你想要什么作用[/quote] 做手机站适配声明: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="mobile-agent" content="format=html5; url=http://32874.com/tu/4571.html"> <meta http-equiv="mobile-agent" content="format=xhtml; url=http://32874.com//tu/4571.html"> <meta http-equiv="Content-Language" content="zh-CN" /> <title>得瑟轻生活</title> </head> <body> 在URL那处放代码,实现自动获取当前后面的字符串
KK3K2005 2015-11-29
  • 打赏
  • 举报
回复
引用 7 楼 meng014131 的回复:
[quote=引用 6 楼 KK3K2005 的回复:] 真作孽 <head> <script type="text/javascript"> document.write(location.pathname); </script> </head>
大神啊,我试过了啊,不起作用[/quote] 你想要什么作用
meng014131 2015-11-28
  • 打赏
  • 举报
回复
引用 6 楼 KK3K2005 的回复:
真作孽 <head> <script type="text/javascript"> document.write(location.pathname); </script> </head>
大神啊,我试过了啊,不起作用
KK3K2005 2015-11-28
  • 打赏
  • 举报
回复
真作孽 <head> <script type="text/javascript"> document.write(location.pathname); </script> </head>
meng014131 2015-11-27
  • 打赏
  • 举报
回复
完全不知道怎么用 继续求完整代码
slwsss 2015-11-27
  • 打赏
  • 举报
回复
document.head.appendChild(document.createTextNode(location.pathname))
meng014131 2015-11-27
  • 打赏
  • 举报
回复
引用 2 楼 slwsss 的回复:
location.pathname
菜鸟能大胆求完整代码吗? 怎么输出到<head> </head>之间啊 <script type="text/javascript"> document.write(location.pathname); </script>
slwsss 2015-11-27
  • 打赏
  • 举报
回复
location.pathname
meng014131 2015-11-27
  • 打赏
  • 举报
回复
我需要 在 <head> 头部调用,如何能做到 菜鸟谢过!

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧