DrDOS
09-19-2010, 04:37 PM
This converts an ordinary 'opens in the same window' HTML page into one with a fullsize click to close popup window. Just link to the script. You can make it ignore URLs you don't want to link to by changing the start and end of the count.
function showImg(URL){
var imgPage="<html><head><title>Click to Close " + URL + "</title><style>body{background-color:#333;color:#d0ffd0;text-align:center}table{width:100%;height:100%;text-align:center}td{text-align:center;vertical-align:middle}img{border:5px solid #d0ffd0}<\/style></head><body onLoad='self.focus();' onClick='self.close();' ><table><tbody><tr><td><img src='" + URL + "'><\/td><\/tr><\/tbody><\/table><\/body><\/html>";
var mywin=open('','','scrollbars=0,toolbar=0');mywin.document.write(imgPage);mywin.document.close();}
function popupWindows() {
if(!document.getElementsByTagName) {
return;
}
var anchors = document.getElementsByTagName("a");
for (var i = 0; i < anchors.length; i++) {
var anchor = anchors[i];
var imgURL = anchor.getAttribute("href");
anchor.setAttribute("href","#");
anchor.setAttribute("onClick","javascript:showImg('" + imgURL + "');");
}}
window.onload = popupWindows;
Here it is in action. It can be a little wonky at times.
http://ronbeau.50webs.com/newalbum/images2.html
function showImg(URL){
var imgPage="<html><head><title>Click to Close " + URL + "</title><style>body{background-color:#333;color:#d0ffd0;text-align:center}table{width:100%;height:100%;text-align:center}td{text-align:center;vertical-align:middle}img{border:5px solid #d0ffd0}<\/style></head><body onLoad='self.focus();' onClick='self.close();' ><table><tbody><tr><td><img src='" + URL + "'><\/td><\/tr><\/tbody><\/table><\/body><\/html>";
var mywin=open('','','scrollbars=0,toolbar=0');mywin.document.write(imgPage);mywin.document.close();}
function popupWindows() {
if(!document.getElementsByTagName) {
return;
}
var anchors = document.getElementsByTagName("a");
for (var i = 0; i < anchors.length; i++) {
var anchor = anchors[i];
var imgURL = anchor.getAttribute("href");
anchor.setAttribute("href","#");
anchor.setAttribute("onClick","javascript:showImg('" + imgURL + "');");
}}
window.onload = popupWindows;
Here it is in action. It can be a little wonky at times.
http://ronbeau.50webs.com/newalbum/images2.html