[Javascript] reload popup with new content???

Dan Costea costea at ssi-schaefer-noell.com
Sat Nov 24 20:09:29 CST 2001


With this example, I hope to give you at least an idea:

I made an object: popupMenu. For using it, you have to have a hidden frame
named: work (you can improve the code so you wouldn't be needed to use that
hidden frame). You can use it like this:

//    global variable:
var myMenu = new popupMenu ('testMenu');


// function that displays a popup menu
function showPopupMenu ()
{
 if (2 == event.button)
 {
  // initializing the popup
  myMenu.emptyMenu ();

  // adding first option
  myMenu.addPopupMenuItem (1, "<IMG src='/pic/my1.gif' style=\'width:12px;
height:12px;\'/> first option", 'onClick="parent.myFunction1()"');

  // adding second option
  myMenu.addPopupMenuItem (1, "<IMG src='/pic/my2.gif' style=\'width:12px;
height:12px;\'/> first option", 'onClick="parent.myFunction2()"');
 }
}


// popup menu object:
function popupMenu (sID)
{
 this.oPopupMenu  = window.createPopup();
 this.sHTMLMenuID = sID;
 this.sHTMLMenu  = getEmptyTable (sID);
 this.nMenuWidth  = 0;
 this.nMenuHeigth = 0;

 this.addPopupMenuItem = addPopupMenuItem;
 this.showMenu = showMenu;
 this.emptyMenu = emptyMenu;
}




function showMenu (posX, posY)
{
 this.oPopupMenu.document.body.innerHTML = this.sHTMLMenu;
 this.oPopupMenu.show (posX, posY, this.nMenuWidth, this.nMenuHeigth);
}




// The function will add items to the popup menu
function addPopupMenuItem (type, text, sFnToCall, oParameters)
{
 // deleting the table tag termination
 oTabEnd = new RegExp ("</TABLE>$");
 this.sHTMLMenu = this.sHTMLMenu.replace (oTabEnd, "");
 var newID = getNewID ();

 this.nItemsNumber++;
 switch (type)
 {
  case 1   :
  case 'option' : this.sHTMLMenu += addOption (text, sFnToCall,
oParameters); break;

  case 2   :
  case 'header' : this.sHTMLMenu += addHeader (text); break;

  case 3   :
  case 'splitter' : this.sHTMLMenu += addSplitter (); break;

  default    : this.nItemsNumber--; // if item not added
 }


 this.sHTMLMenu += "</TABLE>"

 // reading the menu size
 parent.work.document.open ();
 parent.work.document.write (this.sHTMLMenu);
 this.nMenuWidth =
parent.work.document.all[''+this.sHTMLMenuID+''].offsetWidth;
 this.nMenuHeigth =
parent.work.document.all[''+this.sHTMLMenuID+''].offsetHeight;
 parent.work.document.close ();


 function addOption (text, sFnToCall, oParameters)
 {
  var sReturnHTML = '<TR><TD
onMouseOver="style.background=\'darkBlue\';style.color=\'white\';"
onMouseOut="style.background=\'\';style.color=\'\';"'+sFnToCall+'"
nowrap>'+text+'</TD></TR>';

  return sReturnHTML;
 }

 function addHeader (text)
 {
  var sReturnHTML = '<TR><TD><b>'+text+'</b></TD></TR>';

  return sReturnHTML;
 }

 function addSplitter ()
 {
  var sReturnHTML = '<TR><TD><IMG style="width:90px;height:1px"
SRC="'+parent.webapp+'/pic/pixel.gif"></TD></TR>';

  return sReturnHTML;
 }
}




// method
function emptyMenu ()
{
 this.sHTMLMenu = getEmptyTable (this.sHTMLMenuID);
}



function getEmptyTable (sID)
{
 var sMenuTable = "";

 sMenuTable += '<TABLE id="'+sID+'" style="BORDER-RIGHT: black 1px solid;
PADDING-RIGHT: 2px; BORDER-TOP: white 1px solid; PADDING-LEFT: 10px;
FONT-WEIGHT: normal; FONT-SIZE: 8pt; BACKGROUND: #cccccc; LEFT: 0px;
PADDING-BOTTOM: 2px; BORDER-LEFT: white 1px solid; CURSOR: hand; COLOR:
black; PADDING-TOP: 2px; BORDER-BOTTOM: black 1px solid; FONT-FAMILY:
verdana; POSITION: relative; TOP: 0px; HEIGHT: 20px">';
 sMenuTable += '<SCRIPT LANGUAGE="JavaScript">\n';
 sMenuTable += 'window.onerror=null;\n';
 sMenuTable += '</SCRIPT>\n';
 sMenuTable += '</TABLE>';

 return sMenuTable;
}



// function used to create a unique identifier
function getNewID ()
{
 var nTimeStamp = new Date ();
 return "ID" + nTimeStamp.getTime ();
}






----- Original Message -----
From: "Duane Douglas" <ddouglas at mindspring.com>
To: <javascript at LaTech.edu>
Sent: Friday, November 23, 2001 3:04 PM
Subject: [Javascript] reload popup with new content???


> hello,
>
> i want to reload a popup window with new content when i click on
particular
> links on any page.  i want to use only one popup window.  can someone
> please show me how to do this?
>
> tia
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>




More information about the Javascript mailing list