By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,817 Members | 2,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,817 IT Pros & Developers. It's quick & easy.

redirecting

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
sa*****@gwu.edu (slash) writes:
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>
<script type="text/javascript">
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
"slash" <sa*****@gwu.edu> wrote in message
news:30**************************@posting.google.c om...
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?

Jul 20 '05 #3

P: n/a
sa*****@gwu.edu (slash) wrote in
news:30**************************@posting.google.c om:
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.
document.write("https://hfdev1.test.com/rw"+domain2")

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

Jul 20 '05 #4

P: n/a
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/...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" <Ne**@McKirahan.com> wrote in message news:<ktLDb.130599$_M.672066@attbi_s54>...
"slash" <sa*****@gwu.edu> wrote in message
news:30**************************@posting.google.c om...
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?

Jul 20 '05 #5

P: n/a
"slash" <sa*****@gwu.edu> wrote in message
news:30*************************@posting.google.co m...
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/...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" <Ne**@McKirahan.com> wrote in message

news:<ktLDb.130599$_M.672066@attbi_s54>...
"slash" <sa*****@gwu.edu> wrote in message
news:30**************************@posting.google.c om...
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?

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>
Jul 20 '05 #6

P: n/a
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/...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

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.