Forum Moderators: open
[mysite.com...]
I have no idea why the script programmers use such a long query string just to view a single article, partucilarly when the link will work with the entire query string omitted back to the itemid part. I guess they have their reasons, though.
The URL's are dynamically generated, technically, but each article will always have the same URL. Additionally, the various "aspects" of the query string (itemid, action, etc.) will be the same for every article. Only the categories and itemid's will be different.
Anyway, I've written a little script that needs to print a URL to the current page. But, for these purposes, I only need the "necessary" part of the URL. Like I said above, you can get to the same page without using the entire query string. Instead of the example above, the following will work:
[mysite.com...]
So is there any way to use JavaScript to get only that part of the current URL, and ignore the rest of the query string?
Thanks in advance,
Matthew
<script type="text/javascript">
fullurl = window.location.href.split("?");
itemid = fullurl[1].split("itemid=");
finalurl = itemid[1].split("&")[0];
link = fullurl[0]+"?itemid="+finalurl;
document.write(link);
</script> Works great!