Goodies to Go ™
October 6, 2003–Newsletter #253
This newsletter is part of the internet.com network.
http://www.internet.com
Featured this week:
* Goodies Thoughts – Watch Your Language
* Q & A Goodies
* News Goodies
* Goodies Peer Reviews
* Feedback Goodies
* And Remember This…
Goodies Announcement
The new Beyond HTML Goodies book
is now available!
Go beyond the basics
and learn how the pros add and use dynamic HTML features and advanced
JavaScript techniques. Beyond HTML Goodies demonstrates dozens of new and
different features readers can add to their existing Web pages using HTML and
JavaScript. The book starts with simple text and image tips, such as adding a
clock to a Web page or causing text to appear when the mouse moves over an
image. It gradually builds to more complex tricks, including manipulating forms
or working with cookies behind the scenes. Throughout the book, readers enjoy
Joe’s snappy style and “to the point” discussion of each “goody” in the book.
http://books.internet.com/books/0789727803
Goodies Thoughts – Watch Your Language
A friend of mine comes from a Swiss family whose home is close
to the point in Switzerland where the French speaking, German speaking and
Italian speaking sections of the country meet. English is common in Europe due
in part to the number of American TV shows and movies that are shown. My
friend’s family has a home in the Cyclades chain of the Greek islands and spend
most of their summers there. Sitting at the table with them at meal time is
really something! They are all completely fluent in all five languages and
switch from one to the other at any point. One may make a comment in German and
others reply in French or Italian. They may even begin a sentence in English and
finish off the thought in Greek. To each other it makes no difference. To me
it’s a struggle to keep up with what’s going on. I never really learned Italian
(though I did study Latin in school) and my German is very sketchy. (Here, VB
shows restraint and avoids the obvious joke involving the island’s native
tongue!) Asking my friend why they switch like that I was given the explanation
that some things are just easier said in one language, some things are more
expressive said in one language and some things just sound nicer in one
language. It’s all really a question of personal preference.
How closely that matches the world of computer programming! A lot of the time
your choice of language for a particular task will come down to a matter of
personal preference. There are, however, some things that cannot be done on one
language, and require the use of another if they are to happen. (In English we
have the words "yes" and "no" but no word meaning "not yes, and not no either"
to use as an answer for questions like "do you like tall people?" where height
is not one of your criteria for liking people. In at least one Chinese language,
they have just such a word.) In JavaScript there is no file access. That is
because JavaScript is a client side scripting language and nobody wants some
unknown web programmer messing with the files on their computer!
When it comes to programming for the Web, the first basis for selection of a
language is to know whether you need to work on the client side or on the server
side (see
https://www.htmlgoodies.com/letters/207.html in the Goodies To Go Archives
for a discussion of the difference.) It might seem obvious that HTML would be
the first choice for a web page, and that other languages would provide
additional support. That may be true most of the time, but we should not forget
such things as XML which, although it has its roots in the same place as HTML
(SGML) is a language unto itself (see
https://www.htmlgoodies.com/tutors/xml.html for more information.) If you are
just learning HTML, or even if you are wondering if you need to learn it, take
heart! HTML is the driving force of the web. Many languages like PERL and PHP
(both server side, by the way) frequently generate HTML to be interpreted by the
client side browser. By knowing HTML you will have the basis for understanding
what these languages are generating.
JavaScript is undoubtedly the obvious choice in client side scripting languages.
On the server side there is, in addition to the Perl and PHP I have already
mentioned, a very wide choice on languages you could use. On the server side,
you are working on the computer that you control. As such, you are not
constrained by what the client’s computer is capable of, or what they will
permit you to do. Languages like Java, Visual Basic, C, ASP and a host of others
are all there for your choosing. If you don’t know which would be best to use,
the choice is often narrowed by which ones you know or which ones you could
learn the quickest! It so often comes down to personal preference.
The Dot Net Architecture (DNA) is a clever mechanism for extending your choice
of language over to the client side. It has a means to generate some code from
instructions you write in your language of choice that can give you
interactivity on the client side almost as if the client was being brought right
in to your environment. Essentially, the geography is removed from the equation.
If you need to develop interactive web based applications, use of the DNA will
allow you the write code in a variety of languages and have them work together
just like dinner table conversations in my friend’s Greek island home.
So how do you learn all these languages? You can start with the tutorials on
HMTL Goodies, of course! And there are new tutorials being developed as we
speak. Soon you’ll be a poly-lingual, geography surmounting, web programming
guru! Until then, au revoir, vaya con Dios and…
Thanks for Reading!
– Vince Barnes
Q & A Goodies
Questions are taken from submissions to our Community Mentors. You can ask a Mentor a question by going to
https://www.htmlgoodies.com/mentors.
Q. Is there anyway to have a JavaScript object persist across pages
without using an outer frame to store it? I want to store an Array of Window
handles to keep track of which windows our application has opened, and it the
user clicks logout or something like that, I want to be able to iterate through
all the windows that were open and call close(). I decided to put the window
handle in an array every time a use clicked on something that opened a new
window and store that array in the window (like window.WinHandleArray). But if
the user clicks on a link that just loads another document in the same window,
then my window.WinHandleArray is no longer valid. Our application does not
support frames.
A. You could use session only cookies to store the data. Here are a
couple of links to tutorials on the subject:
http://www.javascriptkit.com/javatutors/index.shtml
https://www.htmlgoodies.com/beyond/cookie.html
I also think you should check out a server side language such as PHP or Perl.
They may be more suited to what you want to do. PHP has what are referred to
sessions that allow you to persist variables across documents as long as the
browser session is open.
Q. In my website I link to other websites and those other websites show
up in a frame in my site. However, some of these other websites have popup
scripts in them. Is there a way that my HTML as the parent page can kill or
disable popups generated by the website showing in my frame?
A. No you don’t have any control over those sites and their popups. Also,
if they have code to keep their sites from being displayed in frames you won’t
be able to stop that either.
Q. I would like to make a page that automatically redirects the browser
off to another, different, page that’s randomly selected, but I’m not sure how
to do it using JavaScript.
A. You could place a script like this in the head section of your HTML
document:
<script language="JavaScript"> var linkarr=new Array()
linkarr[0]="http://www.wsabstract.com"
linkarr[1]="http://www.dynamicdrive.com"
linkarr[2]="http://www.requestcode.com"
linkarr[3]="http://www.hotscripts.com"
linkarr[4]="https://www.htmlgoodies.com"
len=linkarr.length // get the number of entries in the array
randnm=Math.round(Math.random()*(len-1)) // generate a random number
location.href=linkarr[randnm] // go to the selected array entry
</script>
Q. I am looking for a cross-browser way (from NS 4 to IE7/Mozilla) to
open a new window without using a popup. On my animal home web site you have the
option to view more pictures of a particular dog/cat by clicking on a link. The
link opens a 300 x 400 popup. The script:
<script type="text/javascript">
function PopupFenster() {
F = window.open("biggi2.htm","biggi","width=300,height=400");
}
</script>
Unfortunately some of my security conscious users have reported they cannot open
the link because they have changed their settings to stop popups. They click and
nothing happens. Most of the users are surfing with Mozilla, others have
dedicated software that prevents popups. Although my popup is actually a chosen
link, it is still drawn into the blanket ban. Is there a way around this?
A. You might take a look at these two scripts:
http://www.dynamicdrive.com/dynamicindex4/imagetooltip.htm
http://www.dynamicdrive.com/dynamicindex4/thumbnail.htm
They both use layers to display the images. The second one sounds more to your
liking.
News Goodies
High Court Denies Infineon Vs. Rambus Appeal
[October 6, 2003] The U.S. Supreme Court refuses to hear
Infineon’s case against Rambus essentially clearing the way for
the Los Altos, Calif.-based company to pursue its own
countersuit.
Click
here to read the article
PeopleSoft Boosts Revenue Expectations
[October 6, 2003] With Oracle’s hostile takeover bid still hovering over its
shoulder, the enterprise software maker brings some better-than-expected
news to shareholders.
Click here to read the article
Rivals EMC, IBM to Work Together
[October 6, 2003] UPDATE: There is no love lost between EMC and IBM, but
both companies show they recognize the importance of working together to
satisfy their customers.
Click here to read the article
Salesforce.com Takes a Simpler Approach to Voice-enablement
[October 6, 2003] Salesforce.com will bring Metro One’s Infone enhanced
directory and personal assistant service to salesforce.com subscribers.
Click here to read the article
A Dose of Web App RealiTea
[October 6, 2003] It’s all science for the new Web analytic from TeaLeaf
Technology, which pinpoints user breakdowns at the source.
Click here to read the article
Globix Expands App Management Capabilities through
Acquisition
[October 6, 2003] MSP Aptegrity’s operations seen as key to
Globix’s plan to become a full-service managed applications
and hosting provider.
Click here to read the article
Intel Perfects Xeon ‘Prestonia’
[October 6, 2003] The chipmaker gives a speed bump to its workhorse dual
processor for servers and workstations on the way to 90-nanometer.
Click here to read the article
Veritas Crafts SRM Software for Windows
[October 6, 2003] Veritas has assimilated the storage resource management (SRM)
product from Precise Software for Windows operating systems.
Click
here to read the article
NetCreations Creates Survey Arm
[October 6, 2003] Under threat from spam laws, the list manager looks
to put its clients’ double opt-in lists to use for market research.
Click here to read the article
Every week a site selected each week for review. Each week,
reviews of the previous week’s selected site are chosen for
publication on the HTML Goodies website.
The current week’s selected site is published in Goodies To
Go and in the Peer Reviews section of the website.
Current contact email addresses for submitting your site and
for submitting reviews are published in Goodies To Go.
If you would like to have your site reviewed, sign up for
the Goodies To Go newsletter in the Navigation Bar on the
left side of this page.
For full details about this program, see
https://www.htmlgoodies.com/peerreviews
Did you ever wish your newsletter was an easy two way communications medium?
Ploof! It now is!
If you would like to comment on the newsletter or expand/improve on something
you have seen in here, you can now send your input to:
mailto:nlfeedback@htmlgoodies.com
We already receive a lot of email every day. This address will help us sort out
those relating specifically to this newsletter from all the rest. When you send
email to this address it may wind up being included in this section of the
newsletter, to be shared with your fellow readers.
Please don’t send your questions to this address.
They should be sent to our mentors: see
https://www.htmlgoodies.com/mentors/
Jose Lorenzo put a lot of effort into this and so I would
like to share it with you (it is included just as he wrote
it – I haven’t tested anything):
Concerning Goodies #252, I suggest 3 different solutions to
Question #1. These overlap with the 2 answers given, but add
detail.
1– The script presented is flawed.
For starters, "if (x=1)…" will always result in true: it
must be fixed to "if (x==1)…."
Secondly, make all the "||" into "&&." Doing that means that
"x" is set to 1 *only if each and every one* of these
illegal symbols are not in "dobday." It then remains to
change the alert trigger to "if (!x)" or equivalent in order
to fix the problem entirely.
Alternatively, we can just change all the "… == -1" to
"… >= 0" [allowing us to keep the ||’s and the "if
(x==1)…" as they are], so that "x=1" happens (and later
triggers the alert) only whenever *any* of the illegal chars
is in "dobday."
A suggestion is that it might be better to check for what
*can* be in dobday instead of for what *can’t* be in it. It
is safer this way and more efficient if only numbers and a
few symbols are legal.
Another suggestion is that no matter the result of the
check, the server should repeat the checks; otherwise, the
server can be fooled/cracked intentionally (maybe, simply by
just disabling javascript… but definitely by a user with
bad intentions and knowledge of http).
Alternate solutions:
2– Do as in https://www.htmlgoodies.com/primers/jsp/hgjsp_29.html
but with a few changes.
Initialize an array by setting the illegal values (used as
indices) to "1". Eg:
var illegalcharsarray = new Array[256];
var illegalcharsstring = "abcdef…[etc]….<>?./|";
for (var i = 0; i < illegalcharsstring.length; i++) {illegalcharsarray[illegalcharsstring.charAt(i)]
= 1;}
Then verify "dobday" is ok by iterating through its values
(as shown through link above), and if "illegalcharsarray[thecharbeingtested]
== 1," we issue the alert.
This solution is more compact than solution 1 and runs
faster. Maintaining it is as simple as updating "illegalcharsstring."
[Note, there are many variations on this idea of iterating
through "dobday" and using a lookup array of illegal chars
(or legal ones, using the reverse logic).]
3– Use regular expressions.
This uses compact code (no explicit looping) and may run the
fastest, but it may not be the most maintainable (especially
if the maintainers aren’t comfortable with javascript
regexps) and is probably not the most portable across web
clients.
Eg:
//globally…
var resultarray;
var a = new RegExp("([0-1]?[0-9])-([0-3]?[0-9])-([1-2][0-9][0-9][0-9])","");
…
//within the verification function…
if (!(resultarray = a.exec(dobdaystring)))
{ /*dobdaystring is in bad format so lets alert user
and reset…. */ }; // "dobdaystring" is the param to
this function and has the dobdate string that was
inserted into the input field.
…
// now to extract the values when all is ok..
var month = resultarray[1];
var day = resultarray[2];
var year = resultarray[3]; // these are already in
int format with no further processing needed.
var undef; resultarray = undef; // do this if want to test
dobday again; it undefines resultarray so that it will be
false unless it is set with a.exec… again or elsewhere.
Other ways are possible.
There are *a lot* of ways to craft a regexp (some, being
more precise, are harder to maintain than others), and we
can even check for what should not be in "dobday" instead of
for what should be in it. We can also allow certain
combination of letters, eg. "jan" and not others.
[Keep in mind that using 3 separate input fields (mo., day,
year) would resolve internationalization issues and just be
simpler for the user. In this case, it may be unnecessary to
use the extraction capabilities of RegExp, and "a.test(…)"
would be a little faster than "a.exec(…)." But we should
still filter the input to remove spaces, etc… i.e., only
allow digits through.]
I apologize if the above has errors. I didn’t have time to
write out all the code, test it, and submit this to Goodies
in time before installment #253. Netscape’s site has links
to Javascript docs.. in particular, to the RegExp object.
Hopefully http://devedge.netscape.com/ still has pointers to
there.
Many thanks Jose!
Thanks again for all your feedback!
Windows Tech Goodie of the Week:
Accessing Shared Resources Using ASP.NET
http://www.15seconds.com/issue/030926.htm
Accessing shared resources is a challenge for many ASP.NET
developers. Tony Arslan explains how a simple serviced
component can solve this infamous
problem.
** and **
A Look at Microsoft’s "Web Data Administrator"
http://www.asp101.com/articles/john/webdataadmin/default.asp
If being able to manage your SQL Server over the internet
seems like a dream then Microsoft’s Web Data Administrator
might just be your wake-up call..
Top
And Remember This . . .
On this day in…
1981 Egyptian President Assassinated
On the first anniversary of the Yom Kipur War Egyptian President
Anwar Sadat was inspecting troops when Khaled al Islambouli, an army
Lieutenant and associate of the Takfir Wal-Hajira terrorist group
together with terrorists also wearing army uniforms fired shots and
threw grenades into the group of Egyptian officials including Sadat.
Sadat was shot four time and died two hours later. Sadat was
instrumental in gaining independence for Egypt. He also turned the
country into a democracy. He and Menachem Begin of Israel were
awarded the Nobel Peace Prize for their efforts in 1977-78 to bring
about peace between their countries. Those same negotiations made
him the target of Mid-Eastern Extremists.
Today was also the day that: in 1683, 13 German families (the
first Mennonites in the Americas) arrive aboard the Concord; 1781
the siege of Yorktown (Americans and French besiege Cornwallis)
begins (it was the last battle of the Revolutionary War); 1866
the first train robbery in the US was perpetrated; 1889
Thomas Edison shows his first motion picture; 1890 the Mormon
church outlawed polygamy; 1939 Hitler announced he had no
intention of war with Britain and France; 1973 Yom Kippur War
begins as Syria and Egypt attack Israel; 1989 actress Bette
Davis died; 1991 Elizabeth Taylor’s 8th wedding (Larry
Fortensky);
Born today were: in 1831 mathematician Richard Dedekind;
1849 arms dealer (the "Merchant of Death") Sir Basil Zaharoff;
1888 Chinese Communist Party co-founder (with Mao Tse-Tung)
Li Ta-Chao; 1914 Norwegian explorer Thor Heyerdahl (Kon Tiki);
1930 Syrian president Hafez al Assad; 1942 Swedish
actress Britt Ekland; 1960 British TV personality Richard
Jobson
Thanks for reading Goodies to Go!