【发布时间】:2012-02-27 01:01:50
【问题描述】:
我正在研究这个问题,但我找不到任何可靠的答案来解决这个特定的目的。假设我有一个网址...
http://mysite.com/stuff/index.php?search=my+search
我怎样才能获取这个 URL 并从中删除 index.php?search=my+search 所以它只是 http://mysite.com/stuff/ ?基本上我只想获取没有文件名的父 URL 或获取变量......无论 URL 是什么(所以我不必为我想要使用它的每个页面自定义函数)
再举一个例子,如果只是……
http://mysite.com/silly.php?hello=ahoy
我只想返回http://mysite.com的根
谁能帮我解决这个问题?我完全迷路了。
【问题讨论】:
标签: javascript jquery regex url variables