Capturing partial URL and using that as part of a link

D

dexterbot

Hi...

I need help in finding a way to capture a partial URL link and then
store that as a variable so that I can use it as part of a hyperlink.
I was hoping Javascripting would allow me to do this since I don't have
PHP engine in our server.

The reason for this is that we have a test environment and a
production. There is a timeout webpage that the user sees when their
session times out after 30 minutes of inactivity. However, every time
we run it thru test, we have to also create another version for
production as the links are different between test and prod. So it
would be nice if we have a way to dynamically generate the hyperlink in
the timeout page based on what URL the user came from.

ie. the URL is http://www.mysite.com/testsite/stage/new/

I want my timeout webpage to be able to identify partial such as
/testsite/ from the URL on the address bar and store that into a
variable and then I need to know how I would be able to create a
dynamic hyperlink for it instead of having to hardcode:
<p><a href="http://www.mysite.com/testsite/login">click to
login</a></p>

Not sure if that makes sense or not... ;P
 
T

Thomas 'PointedEars' Lahn

dexterbot said:
ie. the URL is http://www.mysite.com/testsite/stage/new/

I want my timeout webpage to be able to identify partial such as
/testsite/ from the URL on the address bar and store that into a
variable and then I need to know how I would be able to create a
dynamic hyperlink for it instead of having to hardcode:
<p><a href="http://www.mysite.com/testsite/login">click to
login</a></p>

var s = window.location.href.replace(
/^(https?:\/\/([^\/]+\/){2})stage\/new\//,
"$1login");
Not sure if that makes sense or not... ;P

Probably you are better off using server-side redirection instead.


PointedEars
 
D

dexterbot

That's the problem, I can't use a server-side redirection. I can't
even setup a PHP engine to do PHP otherwise I can probably do PHP to
redirect. It's just a limitation of what we can do here.

Nonetheless, thanks for taking the time to reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top