423,822 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,822 IT Pros & Developers. It's quick & easy.

need to escape HTML chracters with js

P: n/a
I need to escape HTML chracters so <test> --> &lt;test&gt;

Looks like there is no built-in JS function...anyone got one handy ?

thanks
Sep 19 '05 #1
Share this Question
Share on Google+
35 Replies


P: n/a
In alt.www.webmaster, Boobie wrote:
I need to escape HTML chracters so <test> --> &lt;test&gt;

Looks like there is no built-in JS function...anyone got one handy?


I don't do JavaScript, but I do have a question: what happens with
the 10-15% of your visitors who have JavaScript disabled or
unavailable in their browsers?

--
-bts
-This space intentionally left blank.
Sep 19 '05 #2

P: n/a
Writing in news:alt.www.webmaster,comp.lang.javascript
From the safety of the Shagnasty Software cafeteria
Beauregard T. Shagnasty <a.*********@example.invalid> said:
In alt.www.webmaster, Boobie wrote:
I need to escape HTML chracters so <test> --> &lt;test&gt;
Looks like there is no built-in JS function...anyone got one handy?


I don't do JavaScript, but I do have a question: what happens with the
10-15% of your visitors who have JavaScript disabled or unavailable in
their browsers?


hrmm, O/P is not specific - this /could/ be a server-side JS question?

--
William Tasso - Do not meddle in the affairs of dragons, for you are
crunchy and good with ketchup.

g-groups: http://tinyurl.com/e38b2 or http://tinyurl.com/cvsla ?
Sep 19 '05 #3

P: n/a
In alt.www.webmaster, William Tasso wrote:
Writing in news:alt.www.webmaster,comp.lang.javascript From the
safety of the Shagnasty Software cafeteria Beauregard T. Shagnasty
<a.*********@example.invalid> said:
In alt.www.webmaster, Boobie wrote:
I need to escape HTML chracters so <test> --> &lt;test&gt;
Looks like there is no built-in JS function...anyone got one
handy?


I don't do JavaScript, but I do have a question: what happens
with the 10-15% of your visitors who have JavaScript disabled or
unavailable in their browsers?


hrmm, O/P is not specific - this /could/ be a server-side JS
question?


You have a point, Mr. Tasso. At this late hour, I can't think of a
reason to do it client-side. (Speaking of late hours, did you just
crawl out of bed? <g>)

G'nite, now...

--
-bts
-This space intentionally left blank.
Sep 19 '05 #4

P: n/a
"Boobie" schrieb:
I need to escape HTML chracters so <test> --> &lt;test&gt;

Looks like there is no built-in JS function...anyone got one handy ?


What about replace()? ;-)

But as the others said, you should consider doing this on the server
side instead of the client side.

Greetings,
Jan
Sep 19 '05 #5

P: n/a
Boobie wrote:
I need to escape HTML chracters so <test> --> &lt;test&gt;

Looks like there is no built-in JS function...anyone got one handy ?

escapedHTML=szHTML.split("&").join("&amp;").split( "<").join("&lt;").split(">").join("&gt;")
--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.
Sep 19 '05 #6

P: n/a

On Sun, 18 Sep 2005, Boobie wrote:
I need to escape HTML chracters so <test> --> &lt;test&gt;

Looks like there is no built-in JS function...anyone got one handy ?

thanks


Completely untested and could possible reflect my complete
misunderstanding of javascript:

function myescape (foo) {
myfoo = '';
for (i=0;i<length(foo);i++)
{ myfoochar = foo.charAt(i);
if (myfoochar == '<') myfoochar = '&lt;';
if (myfoochar == '>') myfoochar = '&gt;';
if (myfoochar == '&') myfoochar = '&amp;';
// add any other characters you want to handle here
myfoo += myfoochar;
}
return myfoo;
}

....
....
oldbar = '<test>';
newbar = myescape(oldbar);
// newbar should be '&lt;test&gt;'
....
....

--
``Why don't you find a more appropiate newsgroup to post this tripe into?
This is a meeting place for a totally differnt kind of "vision impairment".
Catch my drift?'' -- "jim" in alt.disability.blind.social regarding an
off-topic religious/political post, March 28, 2005

Sep 19 '05 #7

P: n/a

Boobie wrote:
I need to escape HTML chracters so <test> --> &lt;test&gt;

Looks like there is no built-in JS function...anyone got one handy ?

thanks


You could fake it using the encodeURI function in JS;

See -

http://webcoder.info/reference/URIEsc.html

It's really for encoding query strings, but I guess it could also be
used for encoding pages as it converts all non-alpha characters.

Sep 19 '05 #8

P: n/a

On 19 Sep 2005, SpaceGirl wrote:
Boobie wrote:
I need to escape HTML chracters so <test> --> &lt;test&gt;

Looks like there is no built-in JS function...anyone got one handy ?

thanks


You could fake it using the encodeURI function in JS;

See -

http://webcoder.info/reference/URIEsc.html

It's really for encoding query strings, but I guess it could also be
used for encoding pages as it converts all non-alpha characters.


Unless I am totally misunderstanding the documentation for the encodeURI
function, it won't encode '<' and '>' as '&lt;' and '&gt;' but as '%3C'
and '%3E'.

--
``Why don't you find a more appropiate newsgroup to post this tripe into?
This is a meeting place for a totally differnt kind of "vision impairment".
Catch my drift?'' -- "jim" in alt.disability.blind.social regarding an
off-topic religious/political post, March 28, 2005

Sep 19 '05 #9

P: n/a
Whether you use

s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");

or Array.split (Dr Clue)

note that you must remember to do the "&" first, otherwise you will
double escape the &lt; and &gt; references.

Sep 19 '05 #10

P: n/a
And lo, Boobie didst speak in alt.www.webmaster,comp.lang.javascript:
I need to escape HTML chracters so <test> --> &lt;test&gt;

Looks like there is no built-in JS function...anyone got one handy ?


String.replace(/</, "&lt;").replace(/>/, "&gt;");

Grey

--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollary that nothing is ridiculous.
- http://www.greywyvern.com/orca#sear - Orca Search - PHP/MySQL site
search engine
Sep 19 '05 #11

P: n/a
hi Boobie,

Boobie wrote:
I need to escape HTML chracters so <test> --> &lt;test&gt;

Looks like there is no built-in JS function...anyone got one handy ?

thanks


This is taken from "Prototype.js". The best i have ever seen.

String.prototype.extend({
stripTags: function() {
return this.replace(/<\/?[^>]+>/gi, '');
},

escapeHTML: function() {
var div = document.createElement('div');
var text = document.createTextNode(this);
div.appendChild(text);
return div.innerHTML;
},

unescapeHTML: function() {
var div = document.createElement('div');
div.innerHTML = this.stripTags();
return div.childNodes[0].nodeValue;
}
});

-- Peroli Sivaprakasam

Sep 19 '05 #12

P: n/a
JRS: In article <DU******************@twister.nyroc.rr.com>, dated Mon,
19 Sep 2005 04:12:19, seen in news:comp.lang.javascript, Beauregard T.
Shagnasty <a.*********@example.invalid> posted :
hrmm, O/P is not specific - this /could/ be a server-side JS
question?


You have a point, Mr. Tasso. At this late hour, I can't think of a
reason to do it client-side.


There may be no server-side processing. Most of my javascript pages
indirectly use replacement of & < > yet none of them use a server
except for initial delivery :

function SafeHTML(S) {
return S.replace(/&/g, "&amp;").
replace(/</g, "&lt;").replace(/>/g, "&gt;") }

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 19 '05 #13

P: n/a
JRS: In article <V%***************@newsread1.news.pas.earthlink.ne t>,
dated Mon, 19 Sep 2005 04:20:05, seen in news:comp.lang.javascript, Dr Clue
<ia*********@mindspring.com> posted :
...
.split("&").join("&amp;").split("<").join("&lt;"). split(">").join("&gt;")


Have you compared, in various browsers, the speed of that on comparison
with the perhaps more obvious RegExp method? I find it to be annoyingly
quicker.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 19 '05 #14

P: n/a
Dr John Stockton wrote:
JRS: In article <DU******************@twister.nyroc.rr.com>, dated Mon,
19 Sep 2005 04:12:19, seen in news:comp.lang.javascript, Beauregard T.
Shagnasty <a.*********@example.invalid> posted :

hrmm, O/P is not specific - this /could/ be a server-side JS
question?


You have a point, Mr. Tasso. At this late hour, I can't think of a
reason to do it client-side.

There may be no server-side processing. Most of my javascript pages
indirectly use replacement of & < > yet none of them use a server
except for initial delivery :

function SafeHTML(S) {
return S.replace(/&/g, "&amp;").
replace(/</g, "&lt;").replace(/>/g, "&gt;") }


Exactly. Initial delivery should replace them before they go to the
client. Your way will fail when the user has javascript turned off.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 20 '05 #15

P: n/a
On 2005-09-18 23:56:36 -0400, "Boobie" <bo********@mailnull.com> said:
I need to escape HTML chracters so <test> --> &lt;test&gt;

Looks like there is no built-in JS function...anyone got one handy ?

thanks


var stuff=escape("<test>");

will happily escape characters to numerical entities, (i,e, %3Ctest%3E
) as opposed to the named entities in your example. The end result is
pretty much the same though.

Sep 20 '05 #16

P: n/a

"Jerry Stuckle"
You have a point, Mr. Tasso. At this late hour, I can't think of a
reason to do it client-side.



Exactly. Initial delivery should replace them before they go to the
client. Your way will fail when the user has javascript turned off.


Totally agree the escape should be done server-side.

Now...
The reason I need to do this:
I get ResponseText (of raw HTML code) via Ajax.
Beside placing the HTML in the page I also just want to show the ESCAPED
code.

Right now I dump it into TEXTAREA.


Sep 20 '05 #17

P: n/a

"Norman L. DeForest"
It's really for encoding query strings, but I guess it could also be
used for encoding pages as it converts all non-alpha characters.


Unless I am totally misunderstanding the documentation for the encodeURI
function, it won't encode '<' and '>' as '&lt;' and '&gt;' but as '%3C'
and '%3E'.


exactly....that's why none of the "encode" functions that I googled for I
can use.
Sep 20 '05 #18

P: n/a

"Ben Jamieson"
var stuff=escape("<test>");

will happily escape characters to numerical entities, (i,e, %3Ctest%3E
) as opposed to the named entities in your example. The end result is
pretty much the same though.

but...browser displays it as "%3Ctest%3E", that just wont do.
I need it be displayed like "<test>" --- RAW HTML
Sep 20 '05 #19

P: n/a

On Mon, 19 Sep 2005, Boobie wrote:
"Jerry Stuckle"
>You have a point, Mr. Tasso. At this late hour, I can't think of a
>reason to do it client-side.


Exactly. Initial delivery should replace them before they go to the
client. Your way will fail when the user has javascript turned off.


Totally agree the escape should be done server-side.

Now...
The reason I need to do this:
I get ResponseText (of raw HTML code) via Ajax.
Beside placing the HTML in the page I also just want to show the ESCAPED
code.

Right now I dump it into TEXTAREA.


There's one disadvantage to that for Lynx users:

Lynx prints all TEXTAREA data as "_______________________________"
so a user can't use the 'p' (print) command to make a copy of the data.

Fictitious example of such a printout:

To link to our search script, just copy this code into your page:
__________________________________________________ __________
__________________________________________________ __________
__________________________________________________ __________
__________________________________________________ __________
__________________________________________________ __________
__________________________________________________ __________
__________________________________________________ __________

A second disadvantage (if there are long lines of text in the data) is
that Lynx will truncate the display of lines longer than that specified in
the TEXTAREA attributes (or the default width) and you have to move the
cursor to each line separately and then move the cursor back and forth to
scroll the data to read it all. Forget about it completely if any text
lines exceed 256 characters in width.

I really hate sites with terms and conditions you have to read and agree
to to access the site that do that and then have six pages of text with
200 characters per line in a TEXTAREA with a 40-character field width.
I have to cursor to each line and scroll through each line separately to
read (and screen-capture) the text. Why they can't provide a link to an
ordinary readable text version is beyond my comprehension. (OK, viewing
the source, sending it to myself and then viewing the source can be faster
-- provided that it's not in the middle of some login sequence that
doesn't allow page refresh or multiple submissions to fetch the T&C page.)

--
``Why don't you find a more appropiate newsgroup to post this tripe into?
This is a meeting place for a totally differnt kind of "vision impairment".
Catch my drift?'' -- "jim" in alt.disability.blind.social regarding an
off-topic religious/political post, March 28, 2005

Sep 20 '05 #20

P: n/a

On Mon, 19 Sep 2005, Boobie wrote:
"Norman L. DeForest"
It's really for encoding query strings, but I guess it could also be
used for encoding pages as it converts all non-alpha characters.


Unless I am totally misunderstanding the documentation for the encodeURI
function, it won't encode '<' and '>' as '&lt;' and '&gt;' but as '%3C'
and '%3E'.


exactly....that's why none of the "encode" functions that I googled for I
can use.


Was the function I posted of any help? (Or did it not reach your
newsserver?)

--
``Why don't you find a more appropiate newsgroup to post this tripe into?
This is a meeting place for a totally differnt kind of "vision impairment".
Catch my drift?'' -- "jim" in alt.disability.blind.social regarding an
off-topic religious/political post, March 28, 2005

Sep 20 '05 #21

P: n/a
Dr John Stockton wrote:
JRS: In article <V%***************@newsread1.news.pas.earthlink.ne t>,
dated Mon, 19 Sep 2005 04:20:05, seen in news:comp.lang.javascript, Dr Clue
<ia*********@mindspring.com> posted :
...
.split("&").join("&amp;").split("<").join("&lt;" ).split(">").join("&gt;")

Have you compared, in various browsers, the speed of that on comparison
with the perhaps more obvious RegExp method? I find it to be annoyingly
quicker.


Which one was Quicker?

I've never stopped using split/join because it has always worked well
for the purposes I put it to, and I have a habit of using the oldest
technology that will get the job done in an acceptable fashion
(including the effort) to do so.

--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.
Sep 20 '05 #22

P: n/a
Boobie wrote:
"Ben Jamieson"
var stuff=escape("<test>");

will happily escape characters to numerical entities, (i,e, %3Ctest%3E
) as opposed to the named entities in your example. The end result is
pretty much the same though.


but...browser displays it as "%3Ctest%3E", that just wont do.
I need it be displayed like "<test>" --- RAW HTML

Did you get a chance to try my offering?

escapedHTML=szHTML.split("&").join("&amp;").split( "<").join("&lt;").split(">").join("&gt;")

In one line it translates HTML into a form that looks like RAW HTML
when rendered in an HTML page

--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.
Sep 20 '05 #23

P: n/a

"Dr Clue"
Did you get a chance to try my offering?

escapedHTML=szHTML.split("&").join("&amp;").split( "<").join("&lt;").split(">
").join("&gt;")
In one line it translates HTML into a form that looks like RAW HTML
when rendered in an HTML page

yes, that works thanks
Sep 20 '05 #24

P: n/a

"Norman L. DeForest

Was the function I posted of any help? (Or did it not reach your
newsserver?)


you mean the one with this remark :
"Completely untested and could possible reflect my complete
misunderstanding of JavaScript"

Yes I see it...thanks but that way is just wrong.
Sep 20 '05 #25

P: n/a

"Peroli"

This is taken from "Prototype.js". The best i have ever seen.

Ah yes, I know of that library...didn't know that function existed.
Thanks
Sep 20 '05 #26

P: n/a
JRS: In article <yv********************@comcast.com>, dated Mon, 19 Sep
2005 21:54:13, seen in news:comp.lang.javascript, Jerry Stuckle
<js*******@attglobal.net> posted :
Dr John Stockton wrote:
JRS: In article <DU******************@twister.nyroc.rr.com>, dated Mon,
19 Sep 2005 04:12:19, seen in news:comp.lang.javascript, Beauregard T.
Shagnasty <a.*********@example.invalid> posted :

hrmm, O/P is not specific - this /could/ be a server-side JS
question?

You have a point, Mr. Tasso. At this late hour, I can't think of a
reason to do it client-side.

There may be no server-side processing. Most of my javascript pages
indirectly use replacement of & < > yet none of them use a server
except for initial delivery :

function SafeHTML(S) {
return S.replace(/&/g, "&amp;").
replace(/</g, "&lt;").replace(/>/g, "&gt;") }


Exactly. Initial delivery should replace them before they go to the
client. Your way will fail when the user has javascript turned off.

You seem to have failed to notice "There may be no server-side
processing." although you did quote it. I do not use server-side
processing : my pages, once fetched, can be used off-line.

On my pages, it is possible for a reader to execute code of his own,
code that no server has ever seen; and to show it using a function which
calls SafeHTML[*].

I use it in pages (largely about javascript) in which javascript is
provided so that it may be executed to demonstrate an algorithm, either
a general algorithm or a javascript one. That which is shown as the
code is the actual code at the reader's machine; only one copy is
transmitted.

Those reading the pages not about javascript will have to forego seeing
and executing the code if they choose to use a system without
javascript.

Those reading the pages about javascript can reasonably expect to need
to have javascript enabled to get the full flavour as designed.

Those reading the pages not about javascript will have to forego seeing
(in that fashion) and executing the code if they choose to use a system
without javascript.

I guess that you are posting from alt.www.webmaster.

[*] DEMO : with a javascript-enabled browser, paste the following code
into the textarea at
<URL:http://www.merlyn.demon.co.uk/js-demos.htm#Ev>, alter the comment,
and press the Eval button.

function XXX() { /* put your code with & < > here */ }
ShoFFF(XXX, ShoFFF, Depikt)

Further down that page, the double-bordered textareas are what SafeHTML
is *for*.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 20 '05 #27

P: n/a

On Tue, 20 Sep 2005, Boobie wrote:
"Norman L. DeForest

Was the function I posted of any help? (Or did it not reach your
newsserver?)


you mean the one with this remark :
"Completely untested and could possible reflect my complete
misunderstanding of JavaScript"

Yes I see it...thanks but that way is just wrong.


Wrong as in "It doesn't work." or wrong as in "Works but done in the most
inefficient way possible."? :)

Norman "bogosorts'R'us" De Forest
--
``Why don't you find a more appropiate newsgroup to post this tripe into?
This is a meeting place for a totally differnt kind of "vision impairment".
Catch my drift?'' -- "jim" in alt.disability.blind.social regarding an
off-topic religious/political post, March 28, 2005

Sep 20 '05 #28

P: n/a
Dr John Stockton wrote:

You seem to have failed to notice "There may be no server-side
processing." although you did quote it. I do not use server-side
processing : my pages, once fetched, can be used off-line.

On my pages, it is possible for a reader to execute code of his own,
code that no server has ever seen; and to show it using a function which
calls SafeHTML[*].

I use it in pages (largely about javascript) in which javascript is
provided so that it may be executed to demonstrate an algorithm, either
a general algorithm or a javascript one. That which is shown as the
code is the actual code at the reader's machine; only one copy is
transmitted.

Those reading the pages not about javascript will have to forego seeing
and executing the code if they choose to use a system without
javascript.

Those reading the pages about javascript can reasonably expect to need
to have javascript enabled to get the full flavour as designed.

Those reading the pages not about javascript will have to forego seeing
(in that fashion) and executing the code if they choose to use a system
without javascript.

No, I didn't miss the statement. Even though I do server-side
processing on my pages, the *results* can still be used offline. The
only difference is that they are not dynamic.

For instance - if I show a list of products, that list can be saved and
the user can look at it offline. It just won't be updated as inventory
changes.

To me, javascript is a great tool - used to *enhance* websites. But a
website should never *require* javascript to work.

And yes, I am posting from aww. If you don't want responses from this
group also, you should remove it from your list of cross-posted groups.
I guess that you are posting from alt.www.webmaster.
[*] DEMO : with a javascript-enabled browser, paste the following code
into the textarea at
<URL:http://www.merlyn.demon.co.uk/js-demos.htm#Ev>, alter the comment,
and press the Eval button.

function XXX() { /* put your code with & < > here */ }
ShoFFF(XXX, ShoFFF, Depikt)

Further down that page, the double-bordered textareas are what SafeHTML
is *for*.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 21 '05 #29

P: n/a
JRS: In article <88********************@comcast.com>, dated Tue, 20 Sep
2005 22:10:16, seen in news:comp.lang.javascript, Jerry Stuckle
<js*******@attglobal.net> posted :

To me, javascript is a great tool - used to *enhance* websites. But a
website should never *require* javascript to work.


A web page should not fail completely if javascript is not enabled.

But a web page that contains javascript should work better with
javascript enabled, since otherwise there is no point in adding
javascript.

If the added effect is significant, then the reader should be made aware
that, without javascript, he is not getting all the benefit that he
could be getting if he were to enable javascript or use a different
browser/computer. If the added effect is merely decorative, then it's
generally a waste of resources.

In a Web page about javascript, it is reasonable to say that javascript
will be needed to get the full designed effect. However, the mode of
failure if javascript is not enabled should be reasonably benign.

If you want responses only from designers of commercial-type Web pages,
you should not continue cross-posts into news:c.l.j.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 21 '05 #30

P: n/a
Dr John Stockton wrote:


A web page should not fail completely if javascript is not enabled.

Agreed.
But a web page that contains javascript should work better with
javascript enabled, since otherwise there is no point in adding
javascript.

Potentially. Define "work better". Popup menus with alternatives?
Sure. Basic functionality? Nope.
If the added effect is significant, then the reader should be made aware
that, without javascript, he is not getting all the benefit that he
could be getting if he were to enable javascript or use a different
browser/computer. If the added effect is merely decorative, then it's
generally a waste of resources.

Again - define "significant".
In a Web page about javascript, it is reasonable to say that javascript
will be needed to get the full designed effect. However, the mode of
failure if javascript is not enabled should be reasonably benign.

Maybe, maybe not. Depends on the "designed effect". I have a number of
sites with javascript on their pages. And all work just fine if
javascript is disabled.
If you want responses only from designers of commercial-type Web pages,
you should not continue cross-posts into news:c.l.j.


Excuse me... I didn't start this thread, and I didn't put it on
alt.www.webmasters (where "designers of commercial-type Web pages" hang
out).

And anyway, what does "designers of commercial-type Web pages" have to
do with it? Good design is good design, whether you're a commercial
designer or rank amateur. And in fact, maybe some of the amateurs can
learn from the professionals.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 22 '05 #31

P: n/a

On Wed, 21 Sep 2005, Jerry Stuckle wrote:
Dr John Stockton wrote:


A web page should not fail completely if javascript is not enabled.


Agreed.


I partially agree.

A web page should not fail completely if javascript is not enabled
unless the *entire* purpose of the page is to do something that only
JavaScript (or some other scripting language) can do (without requiring
the user to install software).

To create the puzzle in my sig with plain HTML and hyperlinks and no
JavaScript (*without* counting the moves a player has made) would require
pages with 2933884800 different arrangements of the blocks in the puzzle.
If the number of moves a user makes is to be counted, increase that by the
number of duplicates needed, each with a different count. I don't have
enough hard drive space to hold all of that.

Or I could ask the user to install Just BASIC and download my Just BASIC
version of the puzzle. (Ooops, that one is only for my Nova Scotia
puzzle. I haven't coded my Alchemy Mindworks puzzle in Just BASIC yet
and may never do so now that I have a JavaScript version working.)

You could argue that this can be done server-side. Unfortunately, I can't
install scripts on my account. I can implement the puzzle in JavaScript
(which should work for any operating system) or require users to download
a program (wich will work on only one). So, my alternatives were to
create the puzzle using JavaScript and/or Just BASIC or not create it at
all.

(Does anyone know of any free software that would provide an interface
for cgi scripts on my Windows 98 machine so a browser on my machine could
invoke such cgi scripts without my having to install a full-blown web
server? Then I could experiment with writing and invoking cgi scripts
even if I can't install them on my ISP's system.)

--
Can you Change: *alchemy to alchemy* (* == Unicorn)
mindworks mindworks
in 103 moves? Try http://www.chebucto.ns.ca/~af380/AMPuzzle.html
(Requires a browser supporting the W3C DOM such as Firefox or IE ver 6)

Sep 22 '05 #32

P: n/a
Norman L. DeForest wrote:
On Wed, 21 Sep 2005, Jerry Stuckle wrote:

Dr John Stockton wrote:

A web page should not fail completely if javascript is not enabled.

Agreed.

I partially agree.

A web page should not fail completely if javascript is not enabled
unless the *entire* purpose of the page is to do something that only
JavaScript (or some other scripting language) can do (without requiring
the user to install software).


No unless.
To create the puzzle in my sig with plain HTML and hyperlinks and no
JavaScript (*without* counting the moves a player has made) would require
pages with 2933884800 different arrangements of the blocks in the puzzle.
If the number of moves a user makes is to be counted, increase that by the
number of duplicates needed, each with a different count. I don't have
enough hard drive space to hold all of that.

Sorry, I can't play your puzzle.
Or I could ask the user to install Just BASIC and download my Just BASIC
version of the puzzle. (Ooops, that one is only for my Nova Scotia
puzzle. I haven't coded my Alchemy Mindworks puzzle in Just BASIC yet
and may never do so now that I have a JavaScript version working.)

You could argue that this can be done server-side. Unfortunately, I can't
install scripts on my account. I can implement the puzzle in JavaScript
(which should work for any operating system) or require users to download
a program (wich will work on only one). So, my alternatives were to
create the puzzle using JavaScript and/or Just BASIC or not create it at
all.

Get another account. They are cheap and plentiful. Nowadays any host
which won't allow you to install scripts isn't worth the money - even if
it is free.
(Does anyone know of any free software that would provide an interface
for cgi scripts on my Windows 98 machine so a browser on my machine could
invoke such cgi scripts without my having to install a full-blown web
server? Then I could experiment with writing and invoking cgi scripts
even if I can't install them on my ISP's system.)


If you want to use a browser, you need to use a web server. Or, you can
run CGI scripts from the MS DOS prompt.

Just install a web server. I put Apache up on my W2K machine. With
WAMP it's quite easy - and you get MySQL and PHP support also.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 22 '05 #33

P: n/a
JRS: In article <Se********************@comcast.com>, dated Wed, 21 Sep
2005 23:54:11, seen in news:comp.lang.javascript, Jerry Stuckle
<js*******@attglobal.net> posted :
Dr John Stockton wrote:


A web page should not fail completely if javascript is not enabled.

Agreed.
But a web page that contains javascript should work better with
javascript enabled, since otherwise there is no point in adding
javascript.


Potentially. Define "work better". Popup menus with alternatives?
Sure. Basic functionality? Nope.
If the added effect is significant, then the reader should be made aware
that, without javascript, he is not getting all the benefit that he
could be getting if he were to enable javascript or use a different
browser/computer. If the added effect is merely decorative, then it's
generally a waste of resources.


Again - define "significant".


I write for those who can understand English.

In a Web page about javascript, it is reasonable to say that javascript
will be needed to get the full designed effect. However, the mode of
failure if javascript is not enabled should be reasonably benign.


Maybe, maybe not. Depends on the "designed effect". I have a number of
sites with javascript on their pages. And all work just fine if
javascript is disabled.
If you want responses only from designers of commercial-type Web pages,
you should not continue cross-posts into news:c.l.j.


Excuse me... I didn't start this thread, and I didn't put it on
alt.www.webmasters (where "designers of commercial-type Web pages" hang
out).


But you chose to contribute to it, and you chose to continue a cross-
post into news:c.l.j. That choice was your responsibility, and you must
therefore accept the consequences.

And anyway, what does "designers of commercial-type Web pages" have to
do with it? Good design is good design, whether you're a commercial
designer or rank amateur. And in fact, maybe some of the amateurs can
learn from the professionals.


Commercial-type Web pages are those designed, or at least intended, to
be profitable to their providers. To this end, they typically, though
not invariably, use server-side processing to get information from their
users. Commerce is a two-way business.

Others, however, use the Web as a publishing medium; authors provide
information, and in some cases algorithms for readers to execute on
their own systems. That's typical of amateurs and academics (though
some of those do two-way processing too).

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 22 '05 #34

P: n/a
Dr John Stockton wrote:

Again - define "significant".

I write for those who can understand English.


Then you should have no trouble explaining what *you* mean by
"significant". It's not like I'm asking you to define "4".

Excuse me... I didn't start this thread, and I didn't put it on
alt.www.webmasters (where "designers of commercial-type Web pages" hang
out).

But you chose to contribute to it, and you chose to continue a cross-
post into news:c.l.j. That choice was your responsibility, and you must
therefore accept the consequences.


Yes, and you continue to crosspost in a.w.w. There are no consequences
for me.

And anyway, what does "designers of commercial-type Web pages" have to
do with it? Good design is good design, whether you're a commercial
designer or rank amateur. And in fact, maybe some of the amateurs can
learn from the professionals.

Commercial-type Web pages are those designed, or at least intended, to
be profitable to their providers. To this end, they typically, though
not invariably, use server-side processing to get information from their
users. Commerce is a two-way business.

Others, however, use the Web as a publishing medium; authors provide
information, and in some cases algorithms for readers to execute on
their own systems. That's typical of amateurs and academics (though
some of those do two-way processing too).


Interesting. I've developed a lot of web pages for "amateurs and
academics". I used to use it to fill spare time, increase my portfolio
and make a few bucks on the side (most I discounted heavily - but did
not give away).

But I've seen lots of good "non-commercial" sites - almost as many as
I've seen bad "commercial" sites.

Commercial vs. non-commercial has nothing to do with the quality of the
site. Either can be good or bad. Professional webmasters strive to
create good sites - no matter who the client.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 23 '05 #35

P: n/a
Jerry Stuckle said the following on 9/22/2005 11:51 PM:
Dr John Stockton wrote:

Again - define "significant".


I write for those who can understand English.


Then you should have no trouble explaining what *you* mean by
"significant". It's not like I'm asking you to define "4".


Do not expect John to give a definition, it is his MO to make pointed
statements and then when challenged to explain/justify them, he stays
quiet for the most part or dodges the subject.

Excuse me... I didn't start this thread, and I didn't put it on
alt.www.webmasters (where "designers of commercial-type Web pages"
hang out).


But you chose to contribute to it, and you chose to continue a cross-
post into news:c.l.j. That choice was your responsibility, and you must
therefore accept the consequences.


Yes, and you continue to crosspost in a.w.w. There are no consequences
for me.


Precisely. He chooses to continue to cross to aww but if he doesn't want
the aww opinion he should drop it from his replies.

And anyway, what does "designers of commercial-type Web pages" have
to do with it? Good design is good design, whether you're a
commercial designer or rank amateur. And in fact, maybe some of the
amateurs can learn from the professionals.


Commercial-type Web pages are those designed, or at least intended, to
be profitable to their providers. To this end, they typically, though
not invariably, use server-side processing to get information from their
users. Commerce is a two-way business.

Others, however, use the Web as a publishing medium; authors provide
information, and in some cases algorithms for readers to execute on
their own systems. That's typical of amateurs and academics (though
some of those do two-way processing too).

Interesting. I've developed a lot of web pages for "amateurs and
academics". I used to use it to fill spare time, increase my portfolio
and make a few bucks on the side (most I discounted heavily - but did
not give away).

But I've seen lots of good "non-commercial" sites - almost as many as
I've seen bad "commercial" sites.

Commercial vs. non-commercial has nothing to do with the quality of the
site. Either can be good or bad. Professional webmasters strive to
create good sites - no matter who the client.


Exact-amundo :)

Just don't let John know that, he thinks the world revolves around the
Queen Mother and her cronies, errr, subjects.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 23 '05 #36

This discussion thread is closed

Replies have been disabled for this discussion.