The following code creates a simple popup window.
<SCRIPT language="javascript">
<!--- to hide
function myWindow() {
myPopup=open("","myWin","Height=200,Width=300")
myPopup.document.write("This is my Popup window!")
myPopup.document.close()
}
//--->
</SCRIPT>
<FORM>
<input type="button"
value="Click here to pop up a small window!"
onClick="myWindow()">
</FORM>
As you see, the provider at this site allows any author to use popup windows. However,
some providers (especially those who offer free space for site builders) disallow you to
use popups.
How come?—you may ask.
They don’t like those popups because of possible advertising revenue. Those providers basically make
money by placing AD banners in almost every pages at their sites.
If you create a popup window, they have some difficulty in placing those AD banners.
But, even if they allow for popups, it is technically possible for those providers
to place AD banners in popups.
In any case, if those providers keep on disallowing popups, they will loose their customers
in the long run because some other providers allow site builders to use popups.
Here is one of such popup-disallowing sites. Please
click this link: TARGET Made Easy! (A new window will pop up. To return to this page, please
close the new window.)
You see a popup window, but it has nothing inside, and if you take a close look
at the left end of the status bar displayed at the bottom of your screen, you will see
a tiny yellow triangular icon that indicates that the page has a JavaScript error.
What is the status bar?
I can’t see it . . .
If you don’t see one, then click VIEW on the menu bar, you will
see the pull-down menu. Then click Status Bar on the menu, and you will
see the status bar appear on the bottom-left corner of your screen.
When you double-click the tiny yellow icon, you will see the following
popup message box:
Access is denied! Yeeesss! The provider disallows you to use a popup window!
Within a couple of years—I would say—this provide will stop this
ungenerous practice. For I know some providers once disallowed site builders to use
“jump access”. These days, few providers, if not no providers,
remove “jump access” tricks.
The “jump access” allows you to jump to the middle of a page, instead of the
top of the page. When you click the above link, it will guide you to the section that explains
the creation of the popup window.
How come providers don’t like “jump access”?
Well, if they allows for “jump access”, visitors will skip the
top, where the provider usually places an AD banner. This is, the provider cannot make money
from the AD banner. If you see the AD banner and click it and then buy something, the
provider gets a commission.
How to code the “jump access”
Please visit this page: Jump Access. A new window will pop up. To get back here, please
close the new page.
Can you place another page
in a popup window?
When you click this link, you will see the
introduction page to June in a popup window.
The above demo is coded as follows:
<script language="javascript">
<!--- to hide
function newWindow(pic) {
newWin = window.open(pic, 'newWin',
'scrollbars=yes,status=yes,toolbar=yes,
menubar=yes,location=yes,width=600,height=400')
}
//---->
</script>
When you click <a href="javascript:newWindow('june4_en.html')">this link</a>,
you will see the introduction page to June in a popup window.
<form>
<input type="button" value="Click this button for the same page!"
onClick="newWindow('june4_en.html')">
</form>
NOTES
- Because the third parameter of window.open() is too long, it stretches over two lines so that
you can easily see it at a glance.
In the actual code, however, this parameter is NOT divided into two lines.
Don’t divide it. If you do, it doesn’t work properly.
The size of the window might appear quite different from what you have specified.
- In the first example, you see open(), instead of window.open().
Some smart browsers can handle this simpler notation. However, if you write the code by the book,
you have to jot down window.open(). The window means a “window” object
in JavaScript. This page is treated as a document object in JavaScript.
Most of the JavaScript functions (or methods) work on these objects.
So, when you write window.open(), your browser interprets this
as to “open the window object”. If some dumb browsers come across only open(),
they might ask you, “open what?”
The open() and close() are basic JavaScript functions for the window
objects. You can manipulate this window object in so many ways.
For more information on this, please visit this page:
WINDOW Object Basics.
- In the top example, you see myPopup.document.close(). This statement does not mean to
close the window, but interprets like this:
Close the page (document) that was created in
the window object (myPopup). That is, this statement means
to finish writing.
- myWin is a name for the window object (myPopup) so that
you could refer to this object with this name just like “anyName” specified
in TARGET="anyName". If you want to know more about
TARGET, please visit this page: TARGET Made Easy!
Can you place only a picture,
instead of a page?
Yes, you can according to the book. Take a look at the following example:
The code is as follows:
<form>
<input type="button" value="Pop up with only a picture!"
onClick="newWindow('../images/june320.gif')">
</form>
However, you cannot do just that.
“Why not?”—you may ask me.
To see why, please visit this page:
Yes, I can see June Adams in a popup window!
Related Links