Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getURL, modify and got to modified URL

Status
Not open for further replies.

kylebellamy

Programmer
Jan 24, 2002
398
US
For some reason, I can't find a lot of info beyond getting the URL in javascript so I've come back to the best place I know to see if anyone has some code ideas.

I need to create a script that takes the URL from the browser:
(the rest of the url needs to remain the same)

and changes it to:

The resulting URL is then put back into the browser address bar.

This is for a Content Management Server I work on. The first address is the client view of the site and the second is my editing view.

Any ideas as to how this might be done?

 
What have you tried so far? I'll provide some hints for you.

You can get the url via
Code:
location.href
Use this to get the current url replace what you need to using regex or some other method.

Finally forward the url to just edited using something like
Code:
location.href="[URL unfurl="true"]http://www.google.com"[/URL]
 
Well, getting the URL seems to be fairly simple but I can't figure out how to modify it. In this case, there are some 20,000 pages published and a bunch more that are only available in publisher view as they are in progress.

When I get an address from a client it is always using the format. I'm guessing I need to add a variable that replaces the first part of the URL with the new string to be sent back to the browser address bar.

That's where I'm lost. *laughing*

 
This is horrible, but....

Code:
location.href = window.location.protocol + "//" + window.location.hostname.replace('extranet', 'extranetpub') + ":1443" + window.location.pathname + window.location.search;

Please don't judge me, haha.
 
what have you tried so far?
Code:
str = location.href;
str = str.replace(/google/,"yahoo");
 
I am ashamed... just do this:

Code:
location.href = window.location.href.replace(window.location.host, "extranetpub.website.com:1443");
 
This would probably best be done server-side with redirects. That would avoid downloading the page to the client computer, then making another request to the server to the redirected page. It would all be invisible to the client computer, too.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top