Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a popup to work within a frame

Status
Not open for further replies.

inta

Technical User
Aug 2, 2001
13
AU
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=&quot;JavaScript&quot;>
<!-- 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=&quot;JavaScript&quot;>

<!-- Begin
var hmsg = new Array();

hmsg[&quot;home&quot;] = new helpmsg(
&quot;&quot;, &quot;&quot;, &quot;plain&quot;, &quot;Image is very large and may take a long time to download&quot;);

var myPopup = new helpbox(&quot;myPopup&quot;, hmsg, 155, 55, &quot;#ffffee&quot;);

// 275 is the width of the popup box
// 175 is the height of the popup box
// &quot;#ffffee&quot; is the color of the popup box


function helpmsg(header, hstyle, mstyle, message) {
this.DEFAULTHSTYLE = &quot;plain&quot;;
this.DEFAULTMSTYLE = &quot;plain&quot;;

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 = &quot;<FONT FACE='arial'>&quot; + this.header + &quot;</FONT>&quot;;
if (this.hstyle == &quot;h1&quot;) H = &quot;<H1>&quot; + H + &quot;</H1>&quot;;
else if (this.hstyle == &quot;h2&quot;) H = &quot;<H2>&quot; + H + &quot;</H2>&quot;;
else if (this.hstyle == &quot;h3&quot;) H = &quot;<H3>&quot; + H + &quot;</H3>&quot;;
else if (this.hstyle == &quot;h4&quot;) H = &quot;<H4>&quot; + H + &quot;</H4>&quot;;
if (this.hstyle == &quot;fancyheader&quot;) H = &quot;<table width='75%'>&quot; +
&quot;<tr><td bgcolor='#6060ff' align='center' valign='center'>&quot; +
&quot;<H1><FONT COLOR='white'>&quot; + H +
&quot;</FONT></H1>&quot; + &quot;</td></tr></table>&quot;;
else if (this.hstyle == &quot;italics&quot;)
H = &quot;<I>&quot; + H + &quot;</I>&quot;;

var M = &quot;<FONT FACE='arial'>&quot; + this.message + &quot;</FONT>&quot;;
if (this.mstyle == &quot;plain&quot;) {}
if (this.mstyle == &quot;italics&quot;) M = M.italics();
else if (this.mstyle == &quot;bold&quot;) M = M.bold();

var htmlpage = &quot;&quot;;
if (this.hstyle.indexOf(&quot;header&quot;)>=0)
htmlpage = H + M;
else htmlpage = H + &quot;<BR>&quot; + 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 = &quot;#ffffcc&quot;;
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=&quot;top.&quot; + this.name + &quot;.showHelp('&quot; + msgindex + &quot;')&quot;;
this.timerHandle = setTimeout(cmdstr, this.POPUPDELAY);
}
function showHelp(msgindex) {
if (!this.windowHandle || !this.windowHandle.name || this.windowHandle.name==&quot;&quot;)
this.windowHandle = window.open(
&quot;&quot;,
&quot;subWindow&quot;,
&quot;toolbar=no,&quot; +
&quot;location=no,&quot; +
&quot;directories=no,&quot; +
&quot;status=no,&quot; +
&quot;menubar=no,&quot; +
&quot;scrollbars=no,&quot; +
&quot;resizable=no,&quot; +
&quot;width=&quot; + this.width + &quot;,&quot; +
&quot;height=&quot; + this.height
);
else
this.windowHandle.focus();
this.windowHandle.document.open();
var to_page =
&quot;<HTML>\n&quot; +
&quot;<BODY BGCOLOR='&quot; + this.bgcolor + &quot;'><P>&quot; +
this.helpmessage[msgindex].show() +
&quot;</BODY></HTML>\n&quot;;
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=&quot;image-window.html&quot; onclick=&quot;NewWindow(this.href,'name','screen.availWidth','screen.availHeight','yes');return false;&quot; onMouseOver=&quot;myPopup.startHelp('home')&quot; onMouseOut=&quot;myPopup.clearHelp()&quot;><img src=&quot;DC3_roselogo.jpg&quot;></a>
</body>
</head>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top