modifying a function

  • Ruth
  • Newbie
  • Newbie
  • Ruth
  • Posts: 10

Post 3+ Months Ago

Hi,

I have this function, it generates a site index from a dhtml/js menu. What it does is open a new window with a page in it with the site index as a ul li link list on it which means it has a lot of whatever.write for the html stuff. I can change that kind of stuff, for example, I already figured out how to get rid of the ul and to add space instead between the links so it just writes each thing one after the other. But, what i don't know how to do, if it's possible, is stop it from opening a new window and just get the links to be sent to an existing div on the page where the menu is. I've already figured out how to get rid of the target= in the links, but can't figure the sending them to the div and not opening a window with them.
The function, as is without my changes for the ul and stuff:
Code: [ Select ]
var mm_tName;
 
function mm_listMenu(mN)
{
  var j, iN;
 
  _iwd.write("<ul>");
 
  for (j=0; j<_m[mN][0].length; j++)
  {
    iN = _m[mN][0][j];
 
    _iwd.write("<li>");
 
    if (_mi[iN][2] != null) _iwd.write('<a href="' + _mi[iN][2] + '" target="' + mm_tName  + '">');
    _iwd.write(_mi[iN][1]);
    if (_mi[iN][2] != null) _iwd.write('</a>');
 
    if (_mi[iN][3] != null) mm_listMenu(getMenuByName(_mi[iN][3]));
 
    _iwd.write("</li>");
  }
 
  _iwd.write("</ul>");
}
 
function mm_siteIndex(windowAttributes, indexHeading) // , cssFile)
{
  var attr = "toolbar=no,scrollbars=yes,resizable=yes,status=yes";
  if (windowAttributes.length > 0) attr += "," + windowAttributes;
  _iWin = window.open("", "Site_Index", attr);
 
  _iwd = _iWin.document;
 
  if (_iWin.window.opener.name.length == 0) {
    _iWin.window.opener.name = "parentwin";
  }
  mm_tName = _iWin.window.opener.name;
 
  _iwd.open();
  _iwd.write("<html><head><title>Site Index</title>");
 
  if (arguments.length > 2) _iwd.write('<link rel="stylesheet" type="text/css" href="' + arguments[2] + '">');
 
  _iwd.write("</head>");
  _iwd.write("<body>");
  _iwd.write("<h1>" + indexHeading + '</h1>');
 
  for (i=0; i<_m.length; i++)
  {
    if (_m[i][7])
    {
      mm_listMenu(i);
    }
  }
 
  _iwd.write("</body></html>");
 
  _iwd.close();
}
  1. var mm_tName;
  2.  
  3. function mm_listMenu(mN)
  4. {
  5.   var j, iN;
  6.  
  7.   _iwd.write("<ul>");
  8.  
  9.   for (j=0; j<_m[mN][0].length; j++)
  10.   {
  11.     iN = _m[mN][0][j];
  12.  
  13.     _iwd.write("<li>");
  14.  
  15.     if (_mi[iN][2] != null) _iwd.write('<a href="' + _mi[iN][2] + '" target="' + mm_tName  + '">');
  16.     _iwd.write(_mi[iN][1]);
  17.     if (_mi[iN][2] != null) _iwd.write('</a>');
  18.  
  19.     if (_mi[iN][3] != null) mm_listMenu(getMenuByName(_mi[iN][3]));
  20.  
  21.     _iwd.write("</li>");
  22.   }
  23.  
  24.   _iwd.write("</ul>");
  25. }
  26.  
  27. function mm_siteIndex(windowAttributes, indexHeading) // , cssFile)
  28. {
  29.   var attr = "toolbar=no,scrollbars=yes,resizable=yes,status=yes";
  30.   if (windowAttributes.length > 0) attr += "," + windowAttributes;
  31.   _iWin = window.open("", "Site_Index", attr);
  32.  
  33.   _iwd = _iWin.document;
  34.  
  35.   if (_iWin.window.opener.name.length == 0) {
  36.     _iWin.window.opener.name = "parentwin";
  37.   }
  38.   mm_tName = _iWin.window.opener.name;
  39.  
  40.   _iwd.open();
  41.   _iwd.write("<html><head><title>Site Index</title>");
  42.  
  43.   if (arguments.length > 2) _iwd.write('<link rel="stylesheet" type="text/css" href="' + arguments[2] + '">');
  44.  
  45.   _iwd.write("</head>");
  46.   _iwd.write("<body>");
  47.   _iwd.write("<h1>" + indexHeading + '</h1>');
  48.  
  49.   for (i=0; i<_m.length; i++)
  50.   {
  51.     if (_m[i][7])
  52.     {
  53.       mm_listMenu(i);
  54.     }
  55.   }
  56.  
  57.   _iwd.write("</body></html>");
  58.  
  59.   _iwd.close();
  60. }


It's actually the bottom part that has to do with writing that page and opening the index in the new window.

Thanks in advance for any help, even just a 'it's not possible to write links to a div' :)

Ruth
  • Truce
  • Guru
  • Guru
  • Truce
  • Posts: 1477
  • Loc: Washington DC

Post 3+ Months Ago

So the intended behavior is to have every link on the index page be copied into your menu div?
  • Ruth
  • Newbie
  • Newbie
  • Ruth
  • Posts: 10

Post 3+ Months Ago

No, it doesn't do the links that are on the page, it reads the internals of a dhtml js menu and then generates all the items as a ul list that the bottom part opens in a new window.

But, other than that, yes I want the bottom part to not open a new window but write it to say 'div id=selections' on whichever page you are on when you click to generate it. The div would be already on all the pages.

Alternatively, there is a different function which already writes the stuff to a div, but it only writes it as text and I can't figure out how to make the text into links. I'm pretty sure it needs the reference to the url. the _mi[i][1] is the reference number for each item's text and I know the number for the url is _mi[i][2]

Code: [ Select ]
//writes whatever you place here between each item generated
var mm_separator = "&nbsp;&nbsp;<b>~</b>&nbsp;&nbsp;";
 
var mm_selectionSequence = "";
 
//automatically passes the reference to the next page 
function mm_openUrl(url)
{
  url+="?"+_itemRef;
  window.location.href = url;
}
 
// extracts the reference from the parameter passed in the url
// then figures out the sequence of menu items that led to it.
function mm_getSelectionSequence()
{
  var selectedItem = location.search.slice(1);
  var i = selectedItem;
  do {
    if (mm_selectionSequence == "")
      mm_selectionSequence = _mi[i][1];
    else
      mm_selectionSequence = _mi[i][1] + mm_separator + mm_selectionSequence;
    i = getParentItemByItem(i);
  } while (!isNaN(i));
}
  1. //writes whatever you place here between each item generated
  2. var mm_separator = "&nbsp;&nbsp;<b>~</b>&nbsp;&nbsp;";
  3.  
  4. var mm_selectionSequence = "";
  5.  
  6. //automatically passes the reference to the next page 
  7. function mm_openUrl(url)
  8. {
  9.   url+="?"+_itemRef;
  10.   window.location.href = url;
  11. }
  12.  
  13. // extracts the reference from the parameter passed in the url
  14. // then figures out the sequence of menu items that led to it.
  15. function mm_getSelectionSequence()
  16. {
  17.   var selectedItem = location.search.slice(1);
  18.   var i = selectedItem;
  19.   do {
  20.     if (mm_selectionSequence == "")
  21.       mm_selectionSequence = _mi[i][1];
  22.     else
  23.       mm_selectionSequence = _mi[i][1] + mm_separator + mm_selectionSequence;
  24.     i = getParentItemByItem(i);
  25.   } while (!isNaN(i));
  26. }


As is obvious, I know nothing about writing functions, though I can usually figure out what the different things are supposed to be doing.

Thanks :)

Ruth

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 70 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.