473,750 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=javasc ript
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=javasc ript>
if(window.yzq_p ==null)document .write("<scr"+" ipt language=javasc ript
src=http://l.yimg.com/us.js.yimg.com/lib/bc/bc_2.0.4.js></scr"+"ipt>");
</script><script language=javasc ript>
if(window.yzq_p )yzq_p('P=Ri5IO tFJuhuNCf_2Qp5b hM6XRXl91Egegos ABGIP&T=13tvhfk hm%2fX%3d120995 9051%2fE%3d7924 00132%2fR%3ddev _net%2fK%3d5%2f V%3d1.1%2fW%3dJ %2fY%3dYAHOO%2f F%3d1430890299% 2fS%3d1%2fJ%3dC CBB49D1');
if(window.yzq_s )yzq_s();
</script><noscrip t><img width=1 height=1 alt=""
src="http://us.bc.yahoo.com/b?P=Ri5IOtFJuhu NCf_2Qp5bhM6XRX l91EgegosABGIP& T=142luogtl%2fX %3d1209959051%2 fE%3d792400132% 2fR%3ddev_net%2 fK%3d5%2fV%3d3. 1%2fW%3dJ%2fY%3 dYAHOO%2fF%3d38 81337183%2fQ%3d-1%2fS%3d1%2fJ%3 dCCBB49D1"></noscript>
<!-- com3.devnet.re3 .yahoo.com compressed/chunked Sun May 4 20:44:11 PDT
2008 -->
Jun 27 '08 #1
4 1352
"eBob.com" <eB******@total lybogus.comschr eef in bericht
news:BJ******** *************@f e07.news.easyne ws.com...
>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=javasc ript
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

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
Jun 27 '08 #2
On May 9, 1:41 pm, "eBob.com" <eBob....@total lybogus.comwrot e:
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=javasc ript
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=javasc ript>
if(window.yzq_p ==null)document .write("<scr"+" ipt language=javasc ript
src=http://l.yimg.com/us.js.yimg.com/lib/bc/bc_2.0.4.js></scr"+"ipt>");
</script><script language=javasc ript>
[...]

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 <htmltag.
--
Rob
Jun 27 '08 #3
eBob.com wrote:
<snip>
The HTML also contains the following javascript:
document.write( "<scr"+"ipt language=javasc ript 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 "</scriptcharacter 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.

Jun 27 '08 #4


Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1996
by: Ewa | last post by:
Hello I have inherited a www service after someone, I have problems with PHP parts. As I am complete novice. I will be very greatful for your help - I did not managed to find an answer myself. My questions are trivial, I guess. The service is now being moved to another server (PHP 4) and also I would like to run it on my local WAMP (PHP 5) for tests. 1. There's a directory defined there called php_base, which is the root
4
1725
by: Tim Bird | last post by:
Hi all. I have recently installed VB2005 so teach myself programming, could anyone suggest any links to useful websites, or help sites, Ideally I am looking for tutorials, written for the complete novice TIA
3
678
by: Ian | last post by:
'm hoping someone can help me resolve a problem I am having with stylesheets. I've only just started usinbg them so it's more than likely something similar. Trouble is I don't seem to be able to fix it so would be grateful for any help. Basically I'm working with a web page I inherited which has a menu in which the layout/colours are something like this: Heading (always yellow) - Link (always white irrespective of visited or not...
4
1657
by: trond | last post by:
Hello all, Before I start I'd like to point out that I am a complete novice when it comes to asp.net - My background is in network and operating systems, and although I have been doing a bit of hobby programming in vb.net and web programming in asp/vbscript in the past, I am pretty much a beginner at asp.net. What I'm trying to do, is to take the "PersonalHomePage" starter kit that MS supplies with VS2005 and tweak it a bit, to make it...
0
1316
by: James Johnson | last post by:
I have a file that I open a FileStream and a StreamReader for. I issue a SEEK and read a series of records. I then issue another SEEK, no errors, but when I issue the read it picks up where the first read stopped. I have to close the FileStream and the StreamReader, reopen them and then issue the second SEEK. I tried issuing a FLUSH before the second SEEK but the results were the same.
2
1475
by: ducky | last post by:
Hi all, The only programming experience i have under my belt so far is VB. I'm just starting out on C++ and wonder if anybody suggests and good (free) starting points for me to get going. I'm wondering about tutorials, source code, etc... Stuff that will take me from absolute square 1. Also, which compilers would be suggested? i have the bloodshed one and microsoft's visual studio express version as well. Are there any others that...
9
3062
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped. Below you will find the code I've written and the error that results. I'm hoping that someone can give me some direction as to what syntax or parameter is missing from the code that is expected by VBA. Overview: I'm trying to copy calculated...
0
1249
by: Greg Corradini | last post by:
Hello all, I'm having trouble inserting an SQL selection into a new MS Access table. I get a parameter error on my insert statement when I try this (see below for code and error msg). I'm not sure if 'insert' or 'update' is the route I should be taking. CODE: #Import Pythond Standard Library Modules import win32com.client, sys, os, string, copy, glob import mx.ODBC.Windows as odbc
0
1555
by: LK~ICT | last post by:
Sri Lanka rural e-learning project seeks corporate support Dec 04, 2007 (LBO) - A Sri Lankan e-learning initiative for rural students is seeking corporate sector support to expand and cover 400 computer centers around the island, its designers said. The Shilpa Sayura project initiated by eFusion, a local software company, is a learning tool for rural students who do not have the necessary number of teachers and lack resources to...
0
9000
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9339
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6804
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4713
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.