admin管理员组文章数量:1388072
I need to get the whole path of page (excluding the domain) so I can show it in an iframe.
I currently use location.pathname
to get the path, but the problem is that they may appear GET
variables in the URL.
So for a page like article.php?id=23
I get only article.php
using location.pathname
, thus the page displayed in the iframe
is simply a 404 page.
Is there any function to get the path including GET variables?
I need to get the whole path of page (excluding the domain) so I can show it in an iframe.
I currently use location.pathname
to get the path, but the problem is that they may appear GET
variables in the URL.
So for a page like article.php?id=23
I get only article.php
using location.pathname
, thus the page displayed in the iframe
is simply a 404 page.
Is there any function to get the path including GET variables?
Share Improve this question asked Jul 15, 2013 at 20:57 XCSXCS 28.2k28 gold badges104 silver badges153 bronze badges 6- Question already been answer!?stackoverflow./questions/406192/… – saamorim Commented Jul 15, 2013 at 20:59
- I don't see any answer that may help, can you link to that one? – XCS Commented Jul 15, 2013 at 21:00
- look at the bottom right of this page :) – saamorim Commented Jul 15, 2013 at 21:01
-
Well, no answer is helpful, I only need the path including
GET
variables, so hashes for example should be ignored. – XCS Commented Jul 15, 2013 at 21:03 - Ok. Do another finding! :) Information is out there! You'll probably need some substring to select the part before the hash stackoverflow./questions/9513736/… – saamorim Commented Jul 15, 2013 at 21:05
2 Answers
Reset to default 7There probably isn't an out of the box function, no.
But you can use this as a reference to create your own:
Mozilla DOM Reference
Specifically, using window.location.pathname
(strip the leading "/" if you don't want it) and window.location.search
to get the querystring.
i.e
function whatIWant()
{
return window.location.pathname.substring(1) + window.location.search;
}
window.location.search.replace( "?", "" );
this will return the get variables.
LINK=http://www.javascriptkit./jsref/location.shtml
Answer to your question->no,there is no any built in function ,we have to make our custom function and parse it.
Get escaped URL parameter
本文标签: regexGet path including GET variables using javascriptStack Overflow
版权声明:本文标题:regex - Get path including GET variables using javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744567593a2613145.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论