javascript redirect. why is it bad?

Discussion in 'Javascript' started by jeremy, Nov 18, 2006.

  1. jeremy

    jeremy Guest

    In a web app I'm develing for PDA's, I'm using javascript for
    navigation. (document.location = "url"). I've seen a bunch of posts
    on the groups saying this is a bad idea, but no explanations why. Can
    anyone explain?
    jeremy, Nov 18, 2006
    #1
    1. Advertising

  2. jeremy

    Evertjan. Guest

    jeremy wrote on 18 nov 2006 in comp.lang.javascript:

    > In a web app I'm develing for PDA's, I'm using javascript for
    > navigation. (document.location = "url"). I've seen a bunch of posts
    > on the groups saying this is a bad idea, but no explanations why. Can
    > anyone explain?


    I do not know why people say that.
    If you programme for browsers that support it,
    it seems all right.

    However why not write the complete code:

    document.location.href = "url"


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Nov 18, 2006
    #2
    1. Advertising

  3. jeremy

    Randy Webb Guest

    jeremy said the following on 11/18/2006 2:48 PM:
    > In a web app I'm develing for PDA's, I'm using javascript for
    > navigation. (document.location = "url"). I've seen a bunch of posts
    > on the groups saying this is a bad idea, but no explanations why. Can
    > anyone explain?


    If you can ensure that every PDA (or any other UA) that uses your app
    will have scripting enabled, then it's not a problem. The problem comes
    when a UA either doesn't have script enabled, or, it doesn't have
    scripting at all. Then your app is unusable.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Nov 18, 2006
    #3
  4. jeremy

    Randy Webb Guest

    Evertjan. said the following on 11/18/2006 3:01 PM:
    > jeremy wrote on 18 nov 2006 in comp.lang.javascript:
    >
    >> In a web app I'm develing for PDA's, I'm using javascript for
    >> navigation. (document.location = "url"). I've seen a bunch of posts
    >> on the groups saying this is a bad idea, but no explanations why. Can
    >> anyone explain?

    >
    > I do not know why people say that.


    Because it's a bad idea.

    > If you programme for browsers that support it,
    > it seems all right.


    Very true. But what happens when someone with a non-scriptable PDA comes
    along?

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Nov 18, 2006
    #4
  5. jeremy

    jeremy Guest

    Re: javascript redirect. why is it bad?

    Ok, thanks for the info. Our app is restricted to certain users, and w
    can require certain functionality on the platform they are using,
    fortunately.

    Randy Webb wrote:
    > jeremy said the following on 11/18/2006 2:48 PM:
    > > In a web app I'm develing for PDA's, I'm using javascript for
    > > navigation. (document.location = "url"). I've seen a bunch of posts
    > > on the groups saying this is a bad idea, but no explanations why. Can
    > > anyone explain?

    >
    > If you can ensure that every PDA (or any other UA) that uses your app
    > will have scripting enabled, then it's not a problem. The problem comes
    > when a UA either doesn't have script enabled, or, it doesn't have
    > scripting at all. Then your app is unusable.
    >
    > --
    > Randy
    > Chance Favors The Prepared Mind
    > comp.lang.javascript FAQ - http://jibbering.com/faq
    > Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    jeremy, Nov 18, 2006
    #5
  6. jeremy

    Evertjan. Guest

    Randy Webb wrote on 18 nov 2006 in comp.lang.javascript:

    > Evertjan. said the following on 11/18/2006 3:01 PM:
    >> jeremy wrote on 18 nov 2006 in comp.lang.javascript:
    >>
    >>> In a web app I'm develing for PDA's, I'm using javascript for
    >>> navigation. (document.location = "url"). I've seen a bunch of posts
    >>> on the groups saying this is a bad idea, but no explanations why. Can
    >>> anyone explain?

    >>
    >> I do not know why people say that.

    >
    > Because it's a bad idea.
    >
    >> If you programme for browsers that support it,
    >> it seems all right.

    >
    > Very true. But what happens when someone with a non-scriptable PDA comes
    > along?


    Nothing if you programme for browsers that support it [and have it switched
    on], as I said. The non-scriptable PDA simply should be warned it is not
    welcome.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Nov 18, 2006
    #6
  7. jeremy

    pcx99 Guest

    jeremy wrote:
    > In a web app I'm develing for PDA's, I'm using javascript for
    > navigation. (document.location = "url"). I've seen a bunch of posts
    > on the groups saying this is a bad idea, but no explanations why. Can
    > anyone explain?
    >


    Not all browsers have javascript enabled, and javascript navigation can
    make it pretty impossible for the search engines to crawl your site.

    --
    ---------------------------------------------------------------------------
    http://www.hunlock.com -- Permanently under construction (And proud of it!)
    $FA
    pcx99, Nov 18, 2006
    #7
  8. In message <>, Sat, 18 Nov 2006
    15:05:56, Randy Webb <> writes
    >Evertjan. said the following on 11/18/2006 3:01 PM:
    >> jeremy wrote on 18 nov 2006 in comp.lang.javascript:
    >>
    >>> In a web app I'm develing for PDA's, I'm using javascript for
    >>> navigation. (document.location = "url"). I've seen a bunch of posts
    >>> on the groups saying this is a bad idea, but no explanations why. Can
    >>> anyone explain?

    >> I do not know why people say that.

    >
    >Because it's a bad idea.
    >
    >> If you programme for browsers that support it,
    >> it seems all right.

    >
    >Very true. But what happens when someone with a non-scriptable PDA
    >comes along?



    Then its user cannot use THAT METHOD OF navigation.

    If, for example, every page contains an ordinary link to page
    LINKAGES.HTM, and LINKAGES.HTM contains in plain HTML a structured list
    of links to all other pages, then any user who can follow ordinary links
    can access the whole site - and that includes search engines.

    There's nothing wrong with adding javascript navigation as a luxury.

    N.B. "using javascript for" != "using only javascript for".


    Query, for anyone with a NON-FRAMES browser to hand - what does
    <URL:http://www.merlyn.demon.co.uk/frames-1.htm> show?

    With FRAMES working, one can go there and see my site framed; but one
    can de-frame at any time, and re-frame from any(?) HTML page. This the
    use of frames is analogously a reader-selected option, if supported by
    the browser.

    --
    (c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20 ; WinXP.
    Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
    PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
    My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
    Dr J R Stockton, Nov 19, 2006
    #8
  9. jeremy

    Randy Webb Guest

    Dr J R Stockton said the following on 11/19/2006 8:50 AM:
    > In message <>, Sat, 18 Nov 2006
    > 15:05:56, Randy Webb <> writes
    >> Evertjan. said the following on 11/18/2006 3:01 PM:
    >>> jeremy wrote on 18 nov 2006 in comp.lang.javascript:
    >>>
    >>>> In a web app I'm develing for PDA's, I'm using javascript for
    >>>> navigation. (document.location = "url"). I've seen a bunch of posts
    >>>> on the groups saying this is a bad idea, but no explanations why. Can
    >>>> anyone explain?
    >>> I do not know why people say that.

    >> Because it's a bad idea.
    >>
    >>> If you programme for browsers that support it,
    >>> it seems all right.

    >> Very true. But what happens when someone with a non-scriptable PDA
    >> comes along?

    >
    >
    > Then its user cannot use THAT METHOD OF navigation.


    And the OP stated: "I am using javascript for navigation". That does
    *not* imply an HTML fall back.

    > If, for example, every page contains an ordinary link to page
    > LINKAGES.HTM, and LINKAGES.HTM contains in plain HTML a structured list
    > of links to all other pages, then any user who can follow ordinary links
    > can access the whole site - and that includes search engines.


    And anybody that writes code like this:

    <a href="somePage.html" onclick="location.href = this.href;return
    false">Go to some page</a>

    Isn't writing bad code, they are an idiot!

    > There's nothing wrong with adding javascript navigation as a luxury.


    No there isn't, but the OP indicated that was the *only* navigation
    provided and that is a bad idea.

    > N.B. "using javascript for" != "using only javascript for".


    Re-read the thread John. The OP clearly stated it was the only
    navigation, just not in as many words.

    > Query, for anyone with a NON-FRAMES browser to hand - what does
    > <URL:http://www.merlyn.demon.co.uk/frames-1.htm> show?


    Shows a link to your homepage.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Nov 19, 2006
    #9
  10. In comp.lang.javascript message <>,
    Sun, 19 Nov 2006 18:55:54, Randy Webb <> wrote:
    >Dr J R Stockton said the following on 11/19/2006 8:50 AM:
    >> In message <>, Sat, 18 Nov 2006
    >> 15:05:56, Randy Webb <> writes
    >>> Evertjan. said the following on 11/18/2006 3:01 PM:
    >>>> jeremy wrote on 18 nov 2006 in comp.lang.javascript:
    >>>>
    >>>>> In a web app I'm develing for PDA's, I'm using javascript for
    >>>>> navigation. (document.location = "url"). I've seen a bunch of posts
    >>>>> on the groups saying this is a bad idea, but no explanations why. Can
    >>>>> anyone explain?
    >>>> I do not know why people say that.
    >>> Because it's a bad idea.
    >>>
    >>>> If you programme for browsers that support it,
    >>>> it seems all right.
    >>> Very true. But what happens when someone with a non-scriptable PDA
    >>> comes along?

    >> Then its user cannot use THAT METHOD OF navigation.

    >
    >And the OP stated: "I am using javascript for navigation". That does
    >*not* imply an HTML fall back.


    Nor does it imply the absence thereof.

    I use a car to go to a certain place; I do so regularly. But that does
    not mean that I never go there by other means. On Tuesday 7th, I wanted
    to be there earlier, so I walked there.


    My article, in indicating how alternative navigation can be provided,
    acknowledges that without alternative navigation there would be no
    navigation for those not script-capable.

    >> If, for example, every page contains an ordinary link to page
    >> LINKAGES.HTM, and LINKAGES.HTM contains in plain HTML a structured list
    >> of links to all other pages, then any user who can follow ordinary links
    >> can access the whole site - and that includes search engines.

    >
    >And anybody that writes code like this:
    >
    ><a href="somePage.html" onclick="location.href = this.href;return
    >false">Go to some page</a>
    >
    >Isn't writing bad code, they are an idiot!


    You're the first person to have written such code in this branch of this
    thread.



    >> Query, for anyone with a NON-FRAMES browser to hand - what does
    >> <URL:http://www.merlyn.demon.co.uk/frames-1.htm> show?

    >
    >Shows a link to your homepage.


    I hope not; my home page is file c:\*\*.htm on this PC (and, ere long,
    that should need to be in the plural). I dare say that you mean that it
    shows a link to my Web site's Home Page. Thanks; that's what it should
    do.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
    Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
    Plaintext, quoting : see <URL:http://www.usenet.org.uk/ukpost.html>
    Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)
    Dr J R Stockton, Nov 20, 2006
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    864
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    878
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,836
    Smokey Grindel
    Dec 2, 2006
  4. rantingrick
    Replies:
    44
    Views:
    1,204
    Peter Pearson
    Jul 13, 2010
  5. Sal
    Replies:
    1
    Views:
    406
Loading...

Share This Page