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