Hi there,
I have found some HTML/Javascript code that allows either plain text
or an image file to appear in a pop up window.
The original code is at:
Put anything you want in a pop up window
http://webdeveloper.earthweb.com/webjs/item/0,,12760_29601_viewit,00.html
I've trimmed it to make it easier to follow:
--------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Put anything you want into a popup window</title>
</head>
<body onUnload=winClose();>
<script language=JavaScript>
<!--
var NewWin=null
function openNewWin() {
if(NewWin && !NewWin.closed) NewWin.close()
NewWin=window.open("", "NewWin",
"resizable=yes,scrollbars=yes,height=200,width=580,top=100,left=0");
NewWin.document.write("<head><title>Text</title></head>")
NewWin.document.write("<body>")
NewWin.document.write("PLACE TEXT HERE<br>")
NewWin.document.write("PLACE MORE TEXT HERE<br>")
NewWin.document.write("</body>")
}
var NewWin2=null
function openNewWin2() {
if(NewWin2 && !NewWin2.closed) NewWin2.close()
NewWin2=window.open("", "NewWin2",
"resizable=no,height=165,width=200,top=350,left=400");
NewWin2.document.write("<head><title>Images</title></head>")
NewWin2.document.write("<BODY topmargin='0' leftmargin='0'
marginheight='0' marginwidth='0'>")
NewWin2.document.write("<center><img
src='IMAGEFILENAME.JPG'></center>")
NewWin2.document.write("</body>")
}
function winClose(){
if(NewWin && !NewWin.closed) NewWin.close()
if(NewWin2 && !NewWin2.closed) NewWin2.close()
}
//--></SCRIPT>
<p><i>examples: </i><br>
<a href="#" onClick="openNewWin();return false;">Text</a><br>
<a href="#" onClick="openNewWin2();return false;">Image</a>
</p>
</body>
</html>
--------------------
All you need to change is the CODE IN CAPITALS, and the window
sizes...
IMAGE
=====
The image is very straightforward: just replace IMAGEFILENAME.JPG with
a local image file name, like mypicture.jpg, or an external image like
http://website.com/image.gif
Then, four lines above IMAGEFILENAME.JPG you need to change the
dimensions of the window to fit the size of the image you are
displaying.
TEXT
====
The text is almost as easy: just replace PLACE TEXT HERE with the text
you want. For each new line of text just insert extra lines like this,
one after the other:
NewWin.document.write("PLACE MORE TEXT HERE<br>")
Again, three lines above you need to change the dimensions of the
window to fit the size of the image you are displaying. If the text
doesn't fit, there will be scroll bars.
OTHER
=====
- The pop-ups will close automatically when the main page is closed.
It is also impossible to keep clicking on a link and get multiple
pop-ups.
- Any HTML code can be placed between the quotes in lines like this:
NewWin.document.write("<body>")
except if the HTML itself has quotes, then you must replace any
"double quotes" with 'single quotes'. To see more examples, go to the
original code linked to above, save it as a .html file and view it in
your browser.
- In the same line as the window sizes you can have either:
resizable=yes
resizable=no
for whether or not you want the viewer to be able to change the size
of the pop up window.
------------------
Search strategy:
"pop-up window" javascript "plain text"
://www.google.com/search?q=%22pop-up+window%22+javascript+%22plain+text%22
Be sure to ask for a clarification if in anyway this code does not
suit your purposes.
Best wishes,
robertskelton-ga |