JavaScript Code

JavaScript: Create a new window with dynamic contents

This little function will enable you to create a new window and add contents dynamically, you don't need to have an HTML page created to point it to. This is a great tool for pop-up closeups of images and such.

function newWindow(bodyContent, title)
	var newWindow, newContent
	newContent = '<html>'
		+ '<head>'
		+ '<title>' + title + '</title>'
		+ '<link rel="stylesheet" href="styles.css" type="text/css" />'
		+ '</head>'
		+ '<body>'
		+  bodyContent
		+ '</body>'
		+ '</html>';

	newWindow ="","","scrollbars=yes, height=450,width=550");

You could call it like this:

<img src="something_tn.jpg" onclick="newWindow('<img src=something.jpg>','Close up')" />

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image