redirecting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • slash

    redirecting

    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.l ocation.href;
    var domain2 = domain.substr(0 ,29);
    document.write( "https://hfdev1.test.com/rw"+domain2")

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

    Thanks,
    Slash
  • Lasse Reichstein Nielsen

    #2
    Re: redirecting

    satishi@gwu.edu (slash) writes:
    [color=blue]
    > What I am trying to accomplish is the following:
    > -grab the user bookmarked URL.[/color]

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

    "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.
    [color=blue]
    > <HEAD>
    > <script>[/color]

    <script type="text/javascript">
    [color=blue]
    > var domain=window.l ocation.href;
    > var domain2 = domain.substr(0 ,29);[/color]
    [color=blue]
    > document.write( "https://hfdev1.test.com/rw"+domain2")[/color]
    ^ that " is wrong
    [color=blue]
    > function test() {
    > document.locati on.href="https://hfdev1.test.com/rw"+domain2"[/color]
    ^and this[color=blue]
    > }[/color]

    Otherwise it looks fine.
    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • McKirahan

      #3
      Re: redirecting

      "slash" <satishi@gwu.ed u> wrote in message
      news:30fe9f1e.0 312161341.118d7 a8f@posting.goo gle.com...[color=blue]
      > 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.l ocation.href;
      > var domain2 = domain.substr(0 ,29);
      > document.write( "https://hfdev1.test.com/rw"+domain2")
      >
      > function test() {
      > document.locati on.href="https://hfdev1.test.com/rw"+domain2"
      > }
      > </script>
      > </HEAD>
      > <body onload="test()" >
      >
      > Thanks,
      > Slash[/color]


      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?
      [color=blue]
      > -grab the user bookmarked URL.[/color]

      Is this the full URL that invoked the page?
      [color=blue]
      > -strip some of the URL from the beginning[/color]

      What is "some of"? Is the the page's filename?
      [color=blue]
      > -pass what's leftover of the URL and append that to a new URL.[/color]

      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?



      Comment

      • Eric Bohlman

        #4
        Re: redirecting

        satishi@gwu.edu (slash) wrote in
        news:30fe9f1e.0 312161341.118d7 a8f@posting.goo gle.com:
        [color=blue]
        > 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.[/color]
        ^^^^^^^^[color=blue]
        > -i would then like to call this function in the body tag and pass it
        > to onLoad
        >
        > <HEAD>
        > <script>
        > var domain=window.l ocation.href;
        > var domain2 = domain.substr(0 ,29);[/color]

        That gets the first 29 characters of the URL, not the leftovers.
        [color=blue]
        > document.write( "https://hfdev1.test.com/rw"+domain2")
        >
        > function test() {
        > document.locati on.href="https://hfdev1.test.com/rw"+domain2"
        > }
        > </script>
        > </HEAD>
        > <body onload="test()" >[/color]

        Comment

        • slash

          #5
          Re: redirecting

          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(2 9);
          document.write( "https://hfdev1.fhlmc.co m/rw"+domain)

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

          we are migrating our webapp to a new junction. our endusers access
          html files via urls similar
          to the following url:


          our new url path for this same file is at:


          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" <News@McKirahan .com> wrote in message news:<ktLDb.130 599$_M.672066@a ttbi_s54>...[color=blue]
          > "slash" <satishi@gwu.ed u> wrote in message
          > news:30fe9f1e.0 312161341.118d7 a8f@posting.goo gle.com...[color=green]
          > > 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.l ocation.href;
          > > var domain2 = domain.substr(0 ,29);
          > > document.write( "https://hfdev1.test.com/rw"+domain2")
          > >
          > > function test() {
          > > document.locati on.href="https://hfdev1.test.com/rw"+domain2"
          > > }
          > > </script>
          > > </HEAD>
          > > <body onload="test()" >
          > >
          > > Thanks,
          > > Slash[/color]
          >
          >
          > 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?
          >[color=green]
          > > -grab the user bookmarked URL.[/color]
          >
          > Is this the full URL that invoked the page?
          >[color=green]
          > > -strip some of the URL from the beginning[/color]
          >
          > What is "some of"? Is the the page's filename?
          >[color=green]
          > > -pass what's leftover of the URL and append that to a new URL.[/color]
          >
          > 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?[/color]

          Comment

          • McKirahan

            #6
            Re: redirecting

            "slash" <satishi@gwu.ed u> wrote in message
            news:30fe9f1e.0 312170556.d816d f4@posting.goog le.com...[color=blue]
            > 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(2 9);
            > document.write( "https://hfdev1.fhlmc.co m/rw"+domain)
            >
            > function test() {
            > location.href=" https://hfdev1.fhlmc.co m/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" <News@McKirahan .com> wrote in message[/color]
            news:<ktLDb.130 599$_M.672066@a ttbi_s54>...[color=blue][color=green]
            > > "slash" <satishi@gwu.ed u> wrote in message
            > > news:30fe9f1e.0 312161341.118d7 a8f@posting.goo gle.com...[color=darkred]
            > > > 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.l ocation.href;
            > > > var domain2 = domain.substr(0 ,29);
            > > > document.write( "https://hfdev1.test.com/rw"+domain2")
            > > >
            > > > function test() {
            > > > document.locati on.href="https://hfdev1.test.com/rw"+domain2"
            > > > }
            > > > </script>
            > > > </HEAD>
            > > > <body onload="test()" >
            > > >
            > > > Thanks,
            > > > Slash[/color]
            > >
            > >
            > > 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?
            > >[color=darkred]
            > > > -grab the user bookmarked URL.[/color]
            > >
            > > Is this the full URL that invoked the page?
            > >[color=darkred]
            > > > -strip some of the URL from the beginning[/color]
            > >
            > > What is "some of"? Is the the page's filename?
            > >[color=darkred]
            > > > -pass what's leftover of the URL and append that to a new URL.[/color]
            > >
            > > 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?[/color][/color]


            Is this what you're looking for?

            Watch for word-wrap.


            <html>
            <head>
            <title>redirect .htm</title>
            <script language="javas cript" 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(pre f.length,href.l ength);
            location.href = goto + page;
            }
            }
            // -->
            </script>
            </head>
            <body onload="redirec t()">
            </body>
            </html>


            Comment

            • Michael Winter

              #7
              Re: redirecting

              slash wrote on 17 Dec 2003 at Wed, 17 Dec 2003 13:56:30 GMT:
              [color=blue]
              > 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[/color]

              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":



              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":

              6% of the Web's links are broken, diminishing its usability. All old URLs should be kept working indefinitely - otherwise you throw away business.


              Mike

              --
              Michael Winter
              M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk")

              Comment

              Working...