redirecting

S

slash

Hi,
I am new to JavaScript and I have been sifting through the previous
posts about some specific help I need with a redirect problem. No luck
there! Could someone take a look and give me some suggestions. I could
really use some help.

What I am trying to accomplish is the following:
-grab the user bookmarked URL.
-strip some of the URL from the beginning
-pass what's leftover of the URL and append that to a new URL.
-i would then like to call this function in the body tag and pass it
to onLoad

<HEAD>
<script>
var domain=window.location.href;
var domain2 = domain.substr(0,29);
document.write("https://hfdev1.test.com/rw"+domain2")

function test() {
document.location.href="https://hfdev1.test.com/rw"+domain2"
}
</script>
</HEAD>
<body onload="test()">

Thanks,
Slash
 
M

McKirahan

slash said:
Hi,
I am new to JavaScript and I have been sifting through the previous
posts about some specific help I need with a redirect problem. No luck
there! Could someone take a look and give me some suggestions. I could
really use some help.

What I am trying to accomplish is the following:
-grab the user bookmarked URL.
-strip some of the URL from the beginning
-pass what's leftover of the URL and append that to a new URL.
-i would then like to call this function in the body tag and pass it
to onLoad

<HEAD>
<script>
var domain=window.location.href;
var domain2 = domain.substr(0,29);
document.write("https://hfdev1.test.com/rw"+domain2")

function test() {
document.location.href="https://hfdev1.test.com/rw"+domain2"
}
</script>
</HEAD>
<body onload="test()">

Thanks,
Slash


Looks like you're on the right track.

However, you should
a) remove the quotation mark after all references to "domain2"
b) remove the prefixes from all references to "location.href".


Could you provide a better example of what you're trying to do?
-grab the user bookmarked URL.

Is this the full URL that invoked the page?
-strip some of the URL from the beginning

What is "some of"? Is the the page's filename?
-pass what's leftover of the URL and append that to a new URL.

What's the format of the new URL?
Are you passing the "some of" as a querystring?


Give the following URL:
http://{domain}/{folder}/page.htm
what do you want stripped out for later use?
 
L

Lasse Reichstein Nielsen

What I am trying to accomplish is the following:
-grab the user bookmarked URL.

I think you mean the current URL. You don't have access to bookmarks
from Javascript.
-strip some of the URL from the beginning
-pass what's leftover of the URL and append that to a new URL.
-i would then like to call this function in the body tag and pass it
to onLoad

"pass it to onLoad"? That makes no sense. The way to put code into
the body tag is the onload attribute, but you don't pass anything to it.
<HEAD>
<script>

var domain=window.location.href;
var domain2 = domain.substr(0,29);
document.write("https://hfdev1.test.com/rw"+domain2")
^ that " is wrong
function test() {
document.location.href="https://hfdev1.test.com/rw"+domain2" ^and this
}

Otherwise it looks fine.
/L
 
E

Eric Bohlman

(e-mail address removed) (slash) wrote in
What I am trying to accomplish is the following:
-grab the user bookmarked URL.
-strip some of the URL from the beginning
-pass what's leftover of the URL and append that to a new URL. ^^^^^^^^
-i would then like to call this function in the body tag and pass it
to onLoad

<HEAD>
<script>
var domain=window.location.href;
var domain2 = domain.substr(0,29);

That gets the first 29 characters of the URL, not the leftovers.
 
S

slash

Thank you for replying.
Here are the changes I made after your suggestions. I hope this is
what you were talking about.

<script>
var domain=location.href;
var junk = domain.substr(29);
document.write("https://hfdev1.fhlmc.com/rw"+domain)

function test() {
location.href="https://hfdev1.fhlmc.com/rw"+domain
}
</script>

we are migrating our webapp to a new junction. our endusers access
html files via urls similar
to the following url:
https://www.fhlmc.com/swebapps/sell/rworks/docs/mf_svcr/test.html

our new url path for this same file is at:
https://www.fhlmc.com/rw/docs/mf_svcr/test.html

in case you are wondering, the files were copied over to the new
junction.

what i would like to do is to grab the following
part from the old url:

"/docs/mf_svcr/test.html"

and append it to the new url:

"https://www.fhlmc.com/rw" + "/docs/mf_svcr/test.html"

once I have that done, I would like to redirect
the user to that page. So, all of this happens
behind the scenes.

Would this be possible?

Thanks,
Slash
 
M

Michael Winter

slash wrote on 17 Dec 2003 at Wed, 17 Dec 2003 13:56:30 GMT:
we are migrating our webapp to a new junction. our endusers
access html files via urls similar
to the following url:
https://www.fhlmc.com/swebapps/sell/rworks/docs/mf_svcr/test.html

our new url path for this same file is at:
https://www.fhlmc.com/rw/docs/mf_svcr/test.html

Have you tried mapping the path /swebapps/sell/rworks to /rw? Any
decent web server should be able to accomplish this. It also means
that your users can carry on using the old URIs without issue. You
might want to tell them that documents have been moved and they
should change their bookmarks, but if you can keep the mapping in
place permanently, there's no reason to do this.

Take a look at the W3C's brief article on this subject, "Cool URIs
don't change":

http://www.w3.org/Provider/Style/URI

It lists some excuses that people might use to justify altering the
directory structure or naming schemes on a server. It also offers
some tips on how to create stable schemes.

Jakob Nielsen (a well-known name in the field of HCI) has also
written an article on this, "Linkrot":

http://www.useit.com/alertbox/980614.html

Mike
 
M

McKirahan

slash said:
Thank you for replying.
Here are the changes I made after your suggestions. I hope this is
what you were talking about.

<script>
var domain=location.href;
var junk = domain.substr(29);
document.write("https://hfdev1.fhlmc.com/rw"+domain)

function test() {
location.href="https://hfdev1.fhlmc.com/rw"+domain
}
</script>

we are migrating our webapp to a new junction. our endusers access
html files via urls similar
to the following url:
https://www.fhlmc.com/swebapps/sell/rworks/docs/mf_svcr/test.html

our new url path for this same file is at:
https://www.fhlmc.com/rw/docs/mf_svcr/test.html

in case you are wondering, the files were copied over to the new
junction.

what i would like to do is to grab the following
part from the old url:

"/docs/mf_svcr/test.html"

and append it to the new url:

"https://www.fhlmc.com/rw" + "/docs/mf_svcr/test.html"

once I have that done, I would like to redirect
the user to that page. So, all of this happens
behind the scenes.

Would this be possible?

Thanks,
Slash


"McKirahan" <[email protected]> wrote in message


Is this what you're looking for?

Watch for word-wrap.


<html>
<head>
<title>redirect.htm</title>
<script language="javascript" type="text/javascript">
<!--
function redirect() {
var href = location.href;
var pref = "https://www.fhlmc.com/swebapps/sell/rworks/";
if (pref == href.substring(0,pref.length)) {
var goto = "https://www.fhlmc.com/rw/";
var page = href.substr(pref.length,href.length);
location.href = goto + page;
}
}
// -->
</script>
</head>
<body onload="redirect()">
</body>
</html>
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top