Friday, March 29, 2024

Goodies to Go ™
February 2, 2004– Newsletter #270


Goodies to Go ™
February 2, 2004–Newsletter #270

This newsletter is part of the internet.com network.
http://www.internet.com
 


Featured this week:

* Goodies Thoughts – Push You, Pull Me;
Two

* Q & A Goodies
* News Goodies
* Goodies Peer Reviews

* Feedback Goodies  
* Windows Tech 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 – Push You, Pull Me; Two


In last week’s Goodies To Go (see

http://www.htmlgoodies.com/letters/269.html
) I talked about the concepts of
Server Push and Client Pull. I gave descriptions of each but didn’t include
instructions on how to use them. This week I continue with the topic in order to
fill that void.

Let’s start with an example of Client Pull. To re-iterate quickly: Client Pull
is where the client, in this case the web browser that the surfer is using to
request pages from web servers, automatically requests more date from servers,
based on code contained in a page it just retrieved. Put another way, a page
that will use the client pull technique includes code that will initiate a new
request after a period of time.

The simplest method for client pull uses an HTML Meta tag, specifically, the
Meta Refresh. Here’s an example:

<META HTTP-EQUIV="Refresh" CONTENT="10;URL=http://www.displaysecond.com/page2.html">

This tag instructs the browser to fetch another page after a specified number of
seconds. In this example, the browser will go to www.displaysecond.com/page2.html
after displaying the current page for 10 seconds. A value of zero for the
seconds will send the browser to the second page right away. Used creatively,
this could provide a means for changing displayed content every few seconds. You
might, for example, have a frame or iframe in which a series of pages invoke
each other every five seconds, somewhat like a banner rotation.

Server Push, on the other hand, is where the connection between the client
browser an the server is kept open when the client requests a page and following
the initial data send. The server then sends new data down as it sees fit. The
server can keep sending data forever, should it wish to, until the user clicks
"stop" or closes their browser.

Server push can be accomplished by using a variation of the MIME
"multipart/mixed" type that looks like this:

Content-type: multipart/x-mixed-replace;boundary=AnyBoundaryString

The "replace" says that each data block is to replace its predecessor, meaning
that it is displayed in place of, not in addition to, the previous data block
(the first, of course, has nothing to replace.) "AnyBoundaryString" is any
string you choose to mark the boundaries of the data blocks. For example:

Content-type: multipart/x-mixed-replace;boundary=AnyBoundaryString

–AnyBoundaryString
Content-type: text/plain
first set of data content
second line of first set
–AnyBoundaryString
Content-type: text/plain
second set of data content
second line of second set
–AnyBoundaryString
Content-type: text/plain
third and last set of data content
–AnyBoundaryString–

Each "set of data" could be a whole web page, or just a part of one. Notice that
the last of the three sets above ends with a boundary that has two extra dashes
on the end. These terminate the entire message, closing the connection with the
browser and ending the pushing. These don’t ever have to actually be there; I
have included them here just to illustrate how it would be closed if you wanted
to.

If you want to include timing, it has to come from something on the server, such
as a CGI script. Here’s an example of a Unix shell script that, when run as a
CGI script will show who’s currently logged on, and update itself every ten
seconds. It uses the Unix "w" (who) command to provide the information.

#!/bin/sh
echo "HTTP/1.0 200"
echo "Content-type: multipart/x-mixed-replace;boundary=AnyBoundaryString"
echo ""
echo "–AnyBoundaryString"
while true
do
echo "Content-type: text/html"
echo ""
echo "<h2>These users are currently logged on to this system</h2>"
echo "It is now: "
date
echo "<p>"
echo "<plaintext>"
w
echo "–AnyBoundaryString"
sleep 10
done

The first boundary marker is sent, followed by the first set of data and the
second boundary marker. The script then sleeps for ten seconds before repeating
the "do" loop. Sending the next boundary marker before sleeping causes the last
set of data to be displayed while the browser waits for the next set to arrive.
This script never sends a final delimiter, so it will keep on running until the
user ends it.

A little creative thinking coupled to these push/pull techniques can enable some
very interesting things on a website. Remember that you could be using server
push inside a frame or iframe on your main page. You could also be using
combinations of push and pull — the possibilities are endless!
 


Thanks for Reading!
 



– Vince Barnes


 

Top

Q & A Goodies


Questions are taken from submissions to our Community Mentors. You can ask a Mentor a question by going to

http://www.htmlgoodies.com/mentors
.


Q. Is there a way to use a background image
without it repeating? I’d like the bgimg to simply enlarge itself to encompass
each visitor’s window, instead of doing the tile effect.

A. You are not going to be able to get the image to enlarge itself for
every resolution. In fact the site you sent has the image repeating. I even
looked at it on various resolutions and it repeated in all of them. That being
said, you can use some CSS – Cascading Style Sheet – to get an image to only
show once as a background.
Here is the code you should use:
<style type="text/css">
<!– body {background-image: url(images/your_image_name.gif);
background-repeat: no-repeat;} –>
</style>
Make sure you change the path and image name to suit your situation.

Q. This question most specifically refers to JavaScript primer #27 on
http://www.htmlgoodies.com.
I was just wondering if there’s any way to make a link out of each of the
pictures of the slide show, or better yet, open a new window from each with
javascript? (by clicking on the picture of course.) I was also wondering if
there’s a way to make a back one picture button without losing the forward one
picture button. Here’s the code..
<HTML>
<HEAD>
<SCRIPT type="text/javascript">
var num=1
img1 = new Image ()
img1.src = "btent1.jpg"
img2 = new Image ()
img2.src = "btent2.jpg"
img3 = new Image ()
img3.src = "btent3.jpg"
img4 = new Image ()
img4.src = "btent4.jpg"
function slideshow()
{
num=num+1
if (num==5)
{num=1}
document.mypic.src=eval("img"+num+".src")
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#120F56">
<CENTER>
<IMG SRC="btent1.jpg" NAME="mypic" BORDER=0 width="275" height="240"
alt=""> <A HREF="JavaScript:slideshow()"><IMG SRC="rightarrow.gif"
style="position:absolute; top:260px; left:300px" border="0"></A>
</CENTER>
</BODY>
</HTML>

A. Here is a script for a slide show that has a link associated with each
image.
<html><head>
<title>Image and Link Slide Show</title>
<SCRIPT LANGUAGE="JavaScript">
var a=0
// Enter your images Here along with the directory if need be.
var imgs=new Array()
imgs[0]="owls3.jpg"
imgs[1]="hawks2.jpg"
imgs[2]="pic221.jpg"
imgs[3]="eagle1.jpg"
// Array used for preloading
var myimages=new Array()
// Do the preload
for(i=0;i<imgs.length;i++)
{
myimages[i]=new Image()
myimages[i].src=imgs[a]
}
// Enter your URLS and what you want to go in the ALT property. This is so when
they mouse over the image
// There will be a small description of the Image or URL. Make sure you separate
them with an
// ampersand "&" so that the script can separate them out before writing out the
link.
var urls=new Array()
urls[0]="http://www.requestcode.com&Requestcode"
urls[1]="http://www.javascriptkit.com&Javascriptkit"
urls[2]="http://www.dynamicdrive.com&Dynamic Drive"
urls[3]="http://www.htmlgoodies.com&HTML Goodies"

// This is the function that displays the images and links. You should not have
to modify it.
function Doimglink()
{
if(a>imgs.length-1)
{a=0}
if(a<0)
{a=imgs.length-1}
newurls=urls[a].split("&")
if(document.layers)
{
document.mydiv.document.write("<A HREF=’"+newurls[0]+"’><IMG SRC=’"+imgs[a]+"’
BORDER=’0′ ALT=’"+newurls[1]+"’></A>")
document.mydiv.document.close()
}
if(document.getElementById)
{
elm=document.getElementById("mydiv")
elm.innerHTML="<A HREF=’"+newurls[0]+"’><IMG SRC=’"+imgs[a]+"’ BORDER=’0′
TITLE=’"+newurls[1]+"’></A>"
}
}
// function used to display random image
function rannum()
{
len=imgs.length // how many entries in the array
prev=a // Save the previous image index
a=Math.round(Math.random()*(len-1))
// If the current image equals the previous image add one to get a different
image.
if(a==prev)
{a++}
}
window.onload=Doimglink
// In the DIV below you may have to add the top and left properties to the style
tag to position it // correctly in the window. You must keep it positions as
absolute for it to work in NS4.0+ browsers.
</SCRIPT>
</head>
<body onLoad="Doimglink()">
<CENTER><H1>Manual Slide Show With Links</H1>
<DIV ID=’mydiv’ STYLE="position:absolute;top:120;left:200"></DIV>
<DIV ID=’ctrldiv’ STYLE="position:absolute;top:120;left:100">
<A HREF="javascript:a++;Doimglink()">Next Image</A> <BR>
<A HREF="javascript:a–;Doimglink()">Previous Image</A> <BR>
<A HREF="javascript:rannum();Doimglink()">Random Image</A>
</DIV>
</body>
</html>

Q. I am trying to load a new page into a frame with:
top.frame1.document.location="root/subfolder1/subfolder2/filename.htm";
and for some reason it works only if I put an alert before the statement.

A. Try:
top.frame1.location="root/subfolder1/subfolder2/filename.htm";
You can also use:
parent.frame1.location="root/subfolder1/subfolder2/filename.htm";
Either one should work.

Q. I am running a site and many of my articles are being stolen by
copy+paste. Is there a way that when you right click an alert box comes up and
not the regular box with copy and paste on it?

A. First I have to tell you that there is no fool proof way to keep
someone from taking your articles from your web pages. Every time your web page
is displayed on someones PC the page is download to their cache so that it can
be displayed much more quickly. The same goes for any images that are displayed
on the page. Having said that here is a link to a site that has some scripts
that can help:

http://www.dynamicdrive.com/dynamicindex9/index.html

[It’s not a free solution, but you can also provide some protection by creating
password protected PDFs with Adobe Acrobat and including your copyright
information on the pages of your articles. See
http://www.adobe.com for more
information. – Ed.]

 

 

 

 

 

Top

News Goodies


Microsoft Goes Off-Cycle for ‘Critical’ IE Patch
[February 2, 2004] The world’s most popular browser gets an
urgent update to plug several known security holes

Click
here to read the article


 

 

SCO Shifts, Microsoft Braces for Next MyDoom
[February 2, 2004] The beleaguered company moves its home page to avoid the
MyDoom virus; SCO Group says online business is unaffected.

Click here to read the article

 



 

Rich Media Ad Players Irked, Despite Reprieve
[February 2, 2004] Microsoft holds off on releasing the new versions of IE
and Windows that would pose problems for rich media. So why are publishers
and ad serving firms peeved?

Click here to read the article

 

 

Microsoft Kicks Off Server System Campaign
[February 2, 2004] The ads feature hands-on employees who tell how the
product helped them succeed.

Click here to read the article

 

IBM Shifts Products for Industry Verticals
[February 2, 2004] Big Blue targets the crucial financial industry with a
new wave of products geared for its unique problems.

Click
here to read the article

 

 

Infragistics Rolls New .NET Tools
[February 2, 2004] New presentation layer tools for .NET platform are geared
for programmers with disabilities too.

Click here to read the article

 

 

Intel to Bridge its 64-bit Gap with x86
[January 30, 2004] COO Paul Otellini suggests there is still
room for more than just Itanium on the company’s 64-bit
roster of processors.

Click here to read the article

 

 



Dawn of the New Eclipse
[January 30, 2004] Despite IBM’s imminent recession into the background
of Eclipse as the open-source consortium prepares to become a foundation,
Sun has advice for the leaders.

Click here to read the article

 

 



Q&A: Open-Source Guru Eric Raymond
[January 30, 2004] The president of the Open Source Initiative talks
with internetnews.com about lots more than Linux and open source.

Click here to read the article

 

 

IE Patch Could Disrupt E-Commerce
[January 30, 2004] A planned fix for URL spoofing browser flaws could return
error messages on Web sites that use clear text to authenticate user names
and passwords.

Click here to read the article

 

 

 

 

Top


Goodies Peer Reviews


 

Every week a site is selected 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

http://www.htmlgoodies.com/peerreviews

 

 

 

Top

Feedback
Goodies


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
http://www.htmlgoodies.com/mentors/

For those who are missing Peer reviews: we are once again
revising the Peer review program in the hopes of creating a
workable solution. The current plan is to move the new Peer
Review pages into place in the new year. All those who have
been selected for reviews in the past will be featured in
the new pages. The new method will make it much easier for
your peers to provide feedback and much easier for us to
handle the publication side of things. "Watch this space!"
It’s coming soon!!

Many thanks to "Patriot Aussie" Andrew Ross for highlighting
an error in last week’s "On this day". Andrew said that
Australia was settled in 1788 by Captain Cook and that he’d
never heard of Captain Arthur English. Not surprising on
that last part, Andrew — his name was Captain Arthur Philip
— he was English though, and maybe that’s what led to my
typo! On discovering the East coast of "New Holland" in 1770
and naming it "New South Wales", Captain Cook recommended
Botany Bay for colonization. In 1787 the "First Fleet" (9
ships) set sail with 759 convicts, arriving at Botany Bay
between January 18 and 20, 1788. Deeming Botany Bay
unsuitable for settlement, they headed north up the East
Coast of Australia, arriving at Port Jackson on January 26,
1788. Captain Arthur Philip was the leader of the First
Fleet.

And a special thanks goes out to all who write in when you
spot errors — it does my heart a lot of good to know that
you read this newsletter with care — and I am always
impressed with the sharpness of your minds!

Thanks again for all your feedback!
 

Top


 


Windows Tech Goodie of the Week:

 


Database Performance Philosophy


http://www.15seconds.com/issue/040115.htm

Here are some valuable tips on designing databases and
applications for
efficient querying.

*** And ***

Colors ASP.NET Sample Code


http://www.asp101.com/samples/colors_aspx.asp

Basically this script just plays around with some colors. That
said, it’s a
great example of a couple different things. Not only do I use
ASP.NET’s
HTML controls instead of the Web controls that I normally use,
but I also
show you how to apply a style to an HTML control. And if that’s
not
enough… it’s also the first time I’ve published something that
uses the
elusive OnServerClick.

 

 

Top
 
 
 
And Remember This . . .

On this day in…

1971 Idi Amin Declared Himself President of Uganda

On this day in 1971 Idi Amin Dada Oumee, who had the week before
staged a coup (later said to have been supported by Israel and
welcomed by Britain) to oust then Ugandan Prime Minister Milton
Obote, declared himself President of Uganda and Chief of the Armed
Forces. Amin immediately started to purge Uganda of would-be or
could-be enemies by exterminating two-thirds of the army’s 9,000
soldiers in his first year. He expelled 40,000 – 80,000 Indians and
Pakistanis, throwing the country into economic chaos. To secure his
position he embarked on an extermination of rival tribes, killing
between 100,000 and 500,000 (most estimates agree on about 300,000)
of Uganda’s people. In 1979, during conflict with neighboring
Tanzania, Tanzanian forces took Kampala, Uganda’s capital, and Amin
fled to Libya. He eventually settled in Saudi Arabia where, on
August 16, 2003, he died in hospital of multiple organ failure.

Today was also the day that: in 1653 New Amsterdam became a
City (it later became New York); 1848 the first ship of
Chinese immigrants arrived in San Francisco; 1848 the US
acquires Texas, California, New Mexico & Arizona for $15million as
the Mexican War ends with the Treaty of Hidalgo (you’d probably have
to pay a little more today!); 1852 the first British public
toilet, a gents on Fleet Street, opened for "business"; 1870
Mark Twain and Olivia Langdon married in Elmira NY; 1878
Greece declared war on Turkey; 1882 the Knights of Columbus
formed in New Haven CT; 1913 New York’s Grand Central train
terminal opened; 1932 Al Capone was sent to prison in Atlanta
GA; 1940 the Tommy Dorsey Orchestra debuted a new singer in
Indianapolis: Frank Sinatra; 1943 German army surrendered in
the Battle of Stalingrad — the beginning of the end; 1957
Elizabeth Taylor married Mike Todd (number 3); 1964 popular
American boy’s toy GI Joe made his debut (never call it a "doll");
1974 Barbara Streisand made number one for the first time
with "The Way We Were"; 1977 Radio Shack officially began the
TRS-80; 1982 "Late Night with David Letterman" premiered on
NBC; 1990 South African President F.W. DeClerk promised to
free Nelson Mandella and legalized African National Congress (and
about 60 other political organizations); 1992 Willie Nelson
and the IRS agreed to a $9 million settlement for taxes due;

Born today were: in 1650 actress and mistress to King Charles
II Eleanor (Nell) Gwyn; 1861 philanthropist Samuel Guggenheim
(he died on the Titanic); 1882 Irish novelist James Joyce;
1905
writer Ayn Rand; 1920 Wang Labs and Wang Computer
founder An Wang; 1937 opera soprano Martina Arroyo; 1937
comedian Tom Smothers; 1942 musician Graham Nash; 1947
actress Mary Farrah Leni Fawcett; 1954 model/actress Christie
Brinkley; 1955 (2338) actor/android Brent Spiner;
1958
actress Holly Hunter; 1962 actor Michale Weiss;
1963
cartoon character Pebbles Flintstone; 1973 musician
Sergio Gonzalez
 



Thanks for reading Goodies to Go!


 



Archive Home Page.


Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Popular Articles

Featured