javascript redirect. why is it bad?

J

jeremy

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?
 
E

Evertjan.

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

Randy Webb

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.
 
R

Randy Webb

Evertjan. said the following on 11/18/2006 3:01 PM:
jeremy wrote on 18 nov 2006 in comp.lang.javascript:


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?
 
J

jeremy

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.
 
E

Evertjan.

Randy Webb wrote on 18 nov 2006 in comp.lang.javascript:
Evertjan. said the following on 11/18/2006 3:01 PM:

Because it's a bad idea.


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.
 
P

pcx99

jeremy said:
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.
 
D

Dr J R Stockton

Sat said:
Evertjan. said the following on 11/18/2006 3:01 PM:

Because it's a bad idea.


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.
 
R

Randy Webb

Dr J R Stockton said the following on 11/19/2006 8:50 AM:
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.
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>,
Dr J R Stockton said the following on 11/19/2006 8:50 AM:

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.
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.


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.
 

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