I am trying to get a popup to work within a framed page. The script I have is included below. This script works well when the page is not inside a frame.
There is two scripts in the one page that I use. The first script 'NewWindow' open a new window and loads a page - This works.
The second script 'MyPopup' opens a popup when the mouse is passed over the image. This works when the page is loaded on its own but does not work when the page is loaded inside a frame.
If there is another way to do this then I would be happy to use the better method.
Your assistance in getting a working popup within a frame is greatly appreciated.
<html>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// End -->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var hmsg = new Array();
hmsg["home"] = new helpmsg(
"", "", "plain", "Image is very large and may take a long time to download"
var myPopup = new helpbox("myPopup", hmsg, 155, 55, "#ffffee"
// 275 is the width of the popup box
// 175 is the height of the popup box
// "#ffffee" is the color of the popup box
function helpmsg(header, hstyle, mstyle, message) {
this.DEFAULTHSTYLE = "plain";
this.DEFAULTMSTYLE = "plain";
this.header = header;
if (hstyle) this.hstyle = hstyle;
else this.hstyle = this.DEFAULTHSTYLE;
this.message = message;
if (mstyle) this.mstyle = mstyle;
else this.mstyle = this.DEFAULTMSTYLE;
return this;
}
new helpmsg();
helpmsg.prototype.show = show;
function show() {
var H = "<FONT FACE='arial'>" + this.header + "</FONT>";
if (this.hstyle == "h1" H = "<H1>" + H + "</H1>";
else if (this.hstyle == "h2" H = "<H2>" + H + "</H2>";
else if (this.hstyle == "h3" H = "<H3>" + H + "</H3>";
else if (this.hstyle == "h4" H = "<H4>" + H + "</H4>";
if (this.hstyle == "fancyheader" H = "<table width='75%'>" +
"<tr><td bgcolor='#6060ff' align='center' valign='center'>" +
"<H1><FONT COLOR='white'>" + H +
"</FONT></H1>" + "</td></tr></table>";
else if (this.hstyle == "italics"
H = "<I>" + H + "</I>";
var M = "<FONT FACE='arial'>" + this.message + "</FONT>";
if (this.mstyle == "plain" {}
if (this.mstyle == "italics" M = M.italics();
else if (this.mstyle == "bold" M = M.bold();
var htmlpage = "";
if (this.hstyle.indexOf("header">=0)
htmlpage = H + M;
else htmlpage = H + "<BR>" + M;
return htmlpage;
}
function helpbox(name, hm, width, height, bgcolor) {
this.name = name;
this.helpmessage = hm;
this.timerHandle = null;
this.windowHandle = null;
this.DEFAULTWIDTH = 250;
this.DEFAULTHEIGHT = 150;
this.DEFAULTBGCOLOR = "#ffffcc";
this.POPUPDELAY = 100;
if (width) this.width = width;
else this.width = this.DEFAULTWIDTH;
if (height) this.height = height;
else this.height = this.DEFAULTHEIGHT;
if (bgcolor) this.bgcolor = bgcolor;
else this.bgcolor = this.DEFAULTBGCOLOR;
return this;
}
function startHelp(msgindex) {
var cmdstr="top." + this.name + ".showHelp('" + msgindex + "')";
this.timerHandle = setTimeout(cmdstr, this.POPUPDELAY);
}
function showHelp(msgindex) {
if (!this.windowHandle || !this.windowHandle.name || this.windowHandle.name==""
this.windowHandle = window.open(
"",
"subWindow",
"toolbar=no," +
"location=no," +
"directories=no," +
"status=no," +
"menubar=no," +
"scrollbars=no," +
"resizable=no," +
"width=" + this.width + "," +
"height=" + this.height
);
else
this.windowHandle.focus();
this.windowHandle.document.open();
var to_page =
"<HTML>\n" +
"<BODY BGCOLOR='" + this.bgcolor + "'><P>" +
this.helpmessage[msgindex].show() +
"</BODY></HTML>\n";
this.windowHandle.document.write(to_page);
this.windowHandle.document.close();
}
function clearHelp() {
clearTimeout(this.timerHandle);
if (this.windowHandle && this.windowHandle.name) {
this.windowHandle.close();
this.windowHandle=null;
}
}
new helpbox();
helpbox.prototype.startHelp = startHelp;
helpbox.prototype.showHelp = showHelp;
helpbox.prototype.clearHelp = clearHelp;
// End -->
</script>
</HEAD>
<BODY>
<a href="image-window.html" onclick="NewWindow(this.href,'name','screen.availWidth','screen.availHeight','yes');return false;" onMouseOver="myPopup.startHelp('home')" onMouseOut="myPopup.clearHelp()"><img src="DC3_roselogo.jpg"></a>
</body>
</head>
There is two scripts in the one page that I use. The first script 'NewWindow' open a new window and loads a page - This works.
The second script 'MyPopup' opens a popup when the mouse is passed over the image. This works when the page is loaded on its own but does not work when the page is loaded inside a frame.
If there is another way to do this then I would be happy to use the better method.
Your assistance in getting a working popup within a frame is greatly appreciated.
<html>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// End -->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var hmsg = new Array();
hmsg["home"] = new helpmsg(
"", "", "plain", "Image is very large and may take a long time to download"
var myPopup = new helpbox("myPopup", hmsg, 155, 55, "#ffffee"
// 275 is the width of the popup box
// 175 is the height of the popup box
// "#ffffee" is the color of the popup box
function helpmsg(header, hstyle, mstyle, message) {
this.DEFAULTHSTYLE = "plain";
this.DEFAULTMSTYLE = "plain";
this.header = header;
if (hstyle) this.hstyle = hstyle;
else this.hstyle = this.DEFAULTHSTYLE;
this.message = message;
if (mstyle) this.mstyle = mstyle;
else this.mstyle = this.DEFAULTMSTYLE;
return this;
}
new helpmsg();
helpmsg.prototype.show = show;
function show() {
var H = "<FONT FACE='arial'>" + this.header + "</FONT>";
if (this.hstyle == "h1" H = "<H1>" + H + "</H1>";
else if (this.hstyle == "h2" H = "<H2>" + H + "</H2>";
else if (this.hstyle == "h3" H = "<H3>" + H + "</H3>";
else if (this.hstyle == "h4" H = "<H4>" + H + "</H4>";
if (this.hstyle == "fancyheader" H = "<table width='75%'>" +
"<tr><td bgcolor='#6060ff' align='center' valign='center'>" +
"<H1><FONT COLOR='white'>" + H +
"</FONT></H1>" + "</td></tr></table>";
else if (this.hstyle == "italics"
H = "<I>" + H + "</I>";
var M = "<FONT FACE='arial'>" + this.message + "</FONT>";
if (this.mstyle == "plain" {}
if (this.mstyle == "italics" M = M.italics();
else if (this.mstyle == "bold" M = M.bold();
var htmlpage = "";
if (this.hstyle.indexOf("header">=0)
htmlpage = H + M;
else htmlpage = H + "<BR>" + M;
return htmlpage;
}
function helpbox(name, hm, width, height, bgcolor) {
this.name = name;
this.helpmessage = hm;
this.timerHandle = null;
this.windowHandle = null;
this.DEFAULTWIDTH = 250;
this.DEFAULTHEIGHT = 150;
this.DEFAULTBGCOLOR = "#ffffcc";
this.POPUPDELAY = 100;
if (width) this.width = width;
else this.width = this.DEFAULTWIDTH;
if (height) this.height = height;
else this.height = this.DEFAULTHEIGHT;
if (bgcolor) this.bgcolor = bgcolor;
else this.bgcolor = this.DEFAULTBGCOLOR;
return this;
}
function startHelp(msgindex) {
var cmdstr="top." + this.name + ".showHelp('" + msgindex + "')";
this.timerHandle = setTimeout(cmdstr, this.POPUPDELAY);
}
function showHelp(msgindex) {
if (!this.windowHandle || !this.windowHandle.name || this.windowHandle.name==""
this.windowHandle = window.open(
"",
"subWindow",
"toolbar=no," +
"location=no," +
"directories=no," +
"status=no," +
"menubar=no," +
"scrollbars=no," +
"resizable=no," +
"width=" + this.width + "," +
"height=" + this.height
);
else
this.windowHandle.focus();
this.windowHandle.document.open();
var to_page =
"<HTML>\n" +
"<BODY BGCOLOR='" + this.bgcolor + "'><P>" +
this.helpmessage[msgindex].show() +
"</BODY></HTML>\n";
this.windowHandle.document.write(to_page);
this.windowHandle.document.close();
}
function clearHelp() {
clearTimeout(this.timerHandle);
if (this.windowHandle && this.windowHandle.name) {
this.windowHandle.close();
this.windowHandle=null;
}
}
new helpbox();
helpbox.prototype.startHelp = startHelp;
helpbox.prototype.showHelp = showHelp;
helpbox.prototype.clearHelp = clearHelp;
// End -->
</script>
</HEAD>
<BODY>
<a href="image-window.html" onclick="NewWindow(this.href,'name','screen.availWidth','screen.availHeight','yes');return false;" onMouseOver="myPopup.startHelp('home')" onMouseOut="myPopup.clearHelp()"><img src="DC3_roselogo.jpg"></a>
</body>
</head>