Sheesh, I FINALLY took the time to make sure that at least my FRONT page validates with the actual xhtml 1.0 strict DTD that I am using. I will be getting the other pages done as soon as possible as I fix the rest of the site up. I didn’t realize that I hadn’t even LOOKED at SOOOO many of my pages in literally years, and most of them were done when I was first learning xhtml, so they really are a mess.

Anyway, on a slightly different note, I was enlisted to come up with a certain javascript at work, and I was pleased enough with the end result to offer it up for critique and/or download. I barely know javascript at ALL, so any advice, changes, improvements anyone can offer would be greatly appreciated. If it’s well-received I figured I would comment it much better and zip it all up nice and pretty.

Essentially, what was needed was a pop-up script that was resizeable, accessible, and useable across many pages/features. What I came up with APPEARS to work across all browsers and platforms. I have tested it on: Mac – Safari, IE, Opera, Netscape, Camino, and Firefox. PC – IE, Netscape, Opera, and Firefox. It also works in Firefox on Ubuntu Linux. It should also degrade gracefuly is javascript is not enabled. At first I had a little clause in there to check if the popup was already open or not, but for some reason this made it so, if you clicked on the same popup you had just clicked on a second time, it wouldn’t open in the popup, but just in the same window. Weird, but I removed it and it seems to work fine.


//Resizable pop-up window script written by Tricia M. Smith, 5-10-06.
//This script is released under a Creative Commons License (http://creativecommons.org/licenses/by-nc-sa/2.0/)
var newwindow = '';
function popIt(pageName,winWidth,winHeight) {
{
newwindow = window.open(pageName,'mypop','left=200,top=150,height='+winHeight+',width='+winWidth+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
newwindow.resizeTo(winWidth+5,winHeight+50);
}
if (window.focus) {newwindow.focus()}
return false;
}

And here is the code you would use to call the script: 
<a href="pic.jpg" onclick=return popIt(this.href,height,width)">Image</a>

Comments? Questions? Ridicule? 😎

*edit* I almost forgot that of course some may want a demonstration, so I changed the coding of the images in the extended entry here so that you can see how it all works if you like.

Spread the love
Categories: Miscellany