Google Groups Home
Help | Sign in
Novice Seeks Help
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
eBob.com  
View profile
 More options May 8, 11:41 pm
Newsgroups: comp.lang.javascript
From: "eBob.com" <eBob....@totallybogus.com>
Date: Fri, 09 May 2008 03:41:22 GMT
Local: Thurs, May 8 2008 11:41 pm
Subject: Novice Seeks Help
I am trying to understand a bit of JavaScript from
http://developer.yahoo.com/maps/simple/jspost.html  (appended below).  I'd
appreciate help understanding two things it.  The first is the following:
<script  type="text/javascript">
createForms();
</script>
I don't understand the "createForms()".   I know it must be JavaScript but I
have looked in the index of several references and do not find any such
entry in their indices.  My online searches got a few hits but nothing
helpful.  Where can I find some online doc for createForms()?  It seems to
create a button labeled "View on Y! Maps" but where does that text (i.e.
"View on Y! Maps") come from?

The HTML also contains the following JavaScript: document.write("<scr"+"ipt
language=javascript
src=http://l.yimg.com/us.js.yimg.com/lib/bc/bc_2.0.4.js></scr"+"ipt>");.
Why is the concatenation operator, +,  being used here?  To my naive mind it
seems to be unnecessary.

I'll appreciate any help anyone can offer.  Thanks,  Bob

JavaScript from http://developer.yahoo.com/maps/simple/jspost.html ...
<html>
<head>

</head>
<body>
<script  type="text/javascript" src="jspost.js"></script>
<h2>Java script POST sample</h2>
<p>Clicking this Button executes a POST request (Sorry, does not work in
IE)</p>
<p>In this sample the RSS feed is hardcoded. To make this sample into a cool
application, dynamically generate a feed.</p>
<script  type="text/javascript">
createForms();
</script>

</body>
</html>
<!-- spaceId: 792400132 -->
<!-- VER-58 -->
<script language=javascript>
if(window.yzq_p==null)document.write("<scr"+"ipt language=javascript
src=http://l.yimg.com/us.js.yimg.com/lib/bc/bc_2.0.4.js></scr"+"ipt>");
</script><script language=javascript>
if(window.yzq_p)yzq_p('P=Ri5IOtFJuhuNCf_2Qp5bhM6XRXl91EgegosABGIP&T=13tvhfk hm%2fX%3d1209959051%2fE%3d792400132%2fR%3ddev_net%2fK%3d5%2fV%3d1.1%2fW%3dJ %2fY%3dYAHOO%2fF%3d1430890299%2fS%3d1%2fJ%3dCCBB49D1');
if(window.yzq_s)yzq_s();
</script><noscript><img width=1 height=1 alt=""
src="http://us.bc.yahoo.com/b?P=Ri5IOtFJuhuNCf_2Qp5bhM6XRXl91EgegosABGIP&T..."></noscript>
<!-- com3.devnet.re3.yahoo.com compressed/chunked Sun May  4 20:44:11 PDT
2008 -->


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom de Neef  
View profile
 More options May 9, 2:50 am
Newsgroups: comp.lang.javascript
From: "Tom de Neef" <tden...@qolor.nl>
Date: Fri, 9 May 2008 08:50:41 +0200
Local: Fri, May 9 2008 2:50 am
Subject: Re: Novice Seeks Help
"eBob.com" <eBob....@totallybogus.com> schreef in bericht
news:BJPUj.401301$uN4.312173@fe07.news.easynews.com...

a)The html source also contains a line
<script  type="text/javascript" src="jspost.js"></script>
That is a javascript file. It will be loaded and becomes part of all the
javascript on the page. In that file function createForms() will have been
declared. (Try viewing the js file.)

b)The only difference between "script" and "scr"+"ipt" that I can think of
is to make it harder to find script elements in a file via text search in
the source.

Tom


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RobG  
View profile
 More options May 9, 3:00 am
Newsgroups: comp.lang.javascript
From: RobG <rg...@iinet.net.au>
Date: Fri, 9 May 2008 00:00:07 -0700 (PDT)
Local: Fri, May 9 2008 3:00 am
Subject: Re: Novice Seeks Help
On May 9, 1:41 pm, "eBob.com" <eBob....@totallybogus.com> wrote:

> I am trying to understand a bit of JavaScript fromhttp://developer.yahoo.com/maps/simple/jspost.html (appended below).  I'd
> appreciate help understanding two things it.  The first is the following:
> <script  type="text/javascript">
> createForms();
> </script>
> I don't understand the "createForms()".

It is defined as a function in the script file, jspost.js, which is
added to the page by the first script element.

[...]

> The HTML also contains the following JavaScript: document.write("<scr"+"ipt
> language=javascript
> src=http://l.yimg.com/us.js.yimg.com/lib/bc/bc_2.0.4.js></scr"+"ipt>");.
> Why is the concatenation operator, +,  being used here?  To my naive mind it
> seems to be unnecessary.

It is, though it might be used to keep the code tidy.  However, it
seems to have been used above in an attempt to make browsers ignore
the script tags within the string literal when parsing the content of
the script element (which they must do to find the closing </script>
tag)

The example above is erroneous, since the bit that closes the tag is
"</", so that is what must be hidden by escaping the forward slash, so
it should have been written:

  document.write("<script ...>....<\/script>");

Also, the language attribute is deprecated and shouldn't be used, type
is required.

[...]

> </body>
> </html>
> <!-- spaceId: 792400132 -->
> <!-- VER-58 -->
> <script language=javascript>
> if(window.yzq_p==null)document.write("<scr"+"ipt language=javascript
> src=http://l.yimg.com/us.js.yimg.com/lib/bc/bc_2.0.4.js></scr"+"ipt>");
> </script><script language=javascript>

[...]

It is examples like this that create a low opinion of such sites, even
though there are many other exmaples of technical competence.  In
addition to the errors already mentioned, nothing should be placed
after the closing <html> tag.

--
Rob


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Cornford  
View profile
 More options May 9, 3:33 am
Newsgroups: comp.lang.javascript
From: "Richard Cornford" <Rich...@litotes.demon.co.uk>
Date: Fri, 9 May 2008 08:33:58 +0100
Local: Fri, May 9 2008 3:33 am
Subject: Re: Novice Seeks Help
eBob.com wrote:

<snip>

> The HTML also contains the following JavaScript:
> document.write("<scr"+"ipt language=javascript src=http://
> l.yimg.com/us.js.yimg.com/lib/bc/bc_2.0.4.js></scr"+"ipt>");. Why is
> the concatenation operator, +,  being used here?

It is a mystical incantation chanted in the face of an issue that the
author of the page does not understand.

> To my naive mind it seems to be unnecessary.

It is unnecessary (and fails fully address the issue it is aimed at
addressing).

When an HTML parser encounters an opening SCRIPT, where the script
element had content, it needs to work out where the corresponding
closing SCRIPT tag is before it can pass everything in-between into its
javascript interpreter. To do that it can do no more than scan the
following text for some significant character sequence. In the event
that it encounters the character sequence "</script>" it is going to see
that as being the closing SCRIPT tag that corresponds with the opening
one, regardless of where that character sequence may appear (that is.
even if it is inside a javascript string literal the HTML parser will
know nothing about that and just look at the character sequence).

This makes the first concatenation obviously pointless, as the HTML
parser is only interested in closing tags not opening ones. The second
concatenation does have the effect of modifying what may otherwise have
been the character sequence "</script>" and so does render the result
uninteresting to the HTML parser. However, the concatenation is still
unnecessary and adds an avoidable runtime operation because it is
possible to disrupt the "</script> character sequence by inserting a
backslash character into it (which the javascript interpreter will treat
as an escaping character and process out of the string before it
finishes compiling the code). That is, employing the character sequence
"<\/script>" in the javascript string literal is sufficient to prevent
the HTML parser miss-attributing the result as a closing script tag and
avoids the runtime concatenation.

In addition, the HTML specification does not require the HTML parser to
be looking for the "</script>" character sequence, it actually says that
the first occurrence of the character sequence "</" can be taken as
terminating the CDATA content of a SCRIPT element. No browsers have been
observe to be that strict when handling HTML, but there are not
technical grounds for objecting if one was observe to be taking the HTML
specification literally in this regard. You will observe that while the
second concatenation operation above does disrupt the "</script>"
character sequence it does not disrupt the contained "</". Thus though
it may address the issue as observed it fails to address the theoretical
issue, while using the '<\/script>" sequence as an alternative addresses
both (but still leaves all other possible occurrences of mark-up text in
javascript string literals needing some attention given it their closing
tags). (Note that none of this is relevant in javascript files that are
imported with script SRC attributes as they are never exposed to an HTML
parser).

Richard.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Novice Seeks Help - THANKS! to the several responders; you guys are great! [eom]" by eBob.com
eBob.com  
View profile
 More options May 9, 9:47 am
Newsgroups: comp.lang.javascript
From: "eBob.com" <faken...@totallybogus.com>
Date: Fri, 09 May 2008 13:47:06 GMT
Local: Fri, May 9 2008 9:47 am
Subject: Re: Novice Seeks Help - THANKS! to the several responders; you guys are great! [eom]

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google