SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Aug 2002
    Location
    St. Louis, Mo
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with a script

    How can I set these up to do one of two things, open into a new window, and open into a target frame

    a link to an example im working on
    http://www.stlhosting.com/100megs/index1.html

    Code:
    function showToolbar()
    {
    // AddItem(id, text, hint, location, alternativeLocation);
    // AddSubItem(idParent, text, hint, location);
     
    // Main menu
    		menu = new Menu();
    		menu.addItem("homeid", "Home", "Home", "http://stlhosting.com", null);
    		menu.addItem("newsid", "Tools", "Tools", null, null);
    		menu.addItem("systemsid", "Systems", "Systems", null, null);
    		menu.addItem("servicesid", "Services", "Services", null, null);
     
    // Tools Menu
    		menu.addSubItem("systemsid", "DNS Report", "DNS Report", "http://www.dnsreport.com");
    		menu.addSubItem("systemsid", "DNS Stuff", "DNS Stuff", "http://www.dnsstuff.com");
    		menu.addSubItem("systemsid", "Easy WHOIS", "Easy WHOIS", "http://www.easywhois.com");
    		menu.addSubItem("systemsid", "100megs Traffic", "100megs Traffic",
    "");
     
     
    // Services
     
    		menu.addSubItem("servicesid", "Web Designing", "Web Desigining", "http://www.yaaxy.com");
    		menu.addSubItem("servicesid", "Weather", "Weather", "http://www.weather.com");
     
     
    		menu.showMenu();
    }

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this: instead of setting the 'location' parameter to a url, go:
    Code:
    menu.addItem("homeid", "Home", "Home", "javascript:void fn_openPopup('http://stlhosting.com')", null);
    So what's 'fn_openPopup'? Glad you asked.
    Code:
    function fn_openPopup(url)
    {
    	var w = 600;
    	var h = 400;
    	var l = (screen.availWidth - w) / 2;
    	var t = ((screen.availHeight - h) / 2) * .8;
    	smallwin = open(url, 'smallwin', 'width='+w+',height='+h+',left='+l+',top='+t+',menubar,toolbar,location,status,resizable,scrollbars');
    	if (smallwin && !smallwin.closed)
    		smallwin.focus();
    }
    Stick that in one of those .js files. You can use any window-opening script you like as well, or modify the above. For a named frame:
    Code:
    menu.addItem("homeid", "Home", "Home", "javascript:top.frame_name.location='http://stlhosting.com'", null);
    htw (hope that works)

    Edit:

    remove the space in 'resizable'...
    ::: certified wild guess :::

  3. #3
    SitePoint Member
    Join Date
    Aug 2002
    Location
    St. Louis, Mo
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Thanks for the code, however it didn't work. I removed the space like you said, then edited the page and it just shows up blank, no errors. Appears that doesn't work

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would need to see what you actually did.
    ::: certified wild guess :::

  5. #5
    SitePoint Member
    Join Date
    Aug 2002
    Location
    St. Louis, Mo
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok,

    menucontext.js

    Code:
    function fn_openPopup(url)
    {
    var w = 600;
    var h = 400;
    var l = (screen.availWidth - w) / 2;
    var t = ((screen.availHeight - h) / 2) * .8;
    smallwin = open(url, 'smallwin', 'width='+w+',height='+h+',left='+l+',top='+t+',menubar,toolbar,location,status,resizable,scrollbars');
    if (smallwin && !smallwin.closed)
    smallwin.focus();
    }
     
    function showToolbar()
    {
    // AddItem(id, text, hint, location, alternativeLocation);
    // AddSubItem(idParent, text, hint, location);
    // Main menu
    menu = new Menu();
    menu.addItem("homeid", "Home", "Home", "http://support.100megswebhosting.com/tech", null);
    menu.addItem("newsid", "Tools", "Tools", null, null);
    menu.addItem("systemsid", "Systems", "Systems", null, null);
    menu.addItem("servicesid", "Services", "Services", null, null);
    menu.addItem("homeid", "Home", "Home", "java_script_:void fn_openPopup('http://stlhosting.com')", null);
    // Tools Menu
    menu.addSubItem("systemsid", "DNS Report", "DNS Report", "http://www.dnsreport.com");
    menu.addSubItem("systemsid", "DNS Stuff", "DNS Stuff", "http://www.dnsstuff.com");
    menu.addSubItem("systemsid", "Easy WHOIS", "Easy WHOIS", "http://www.easywhois.com");
    menu.addSubItem("systemsid", "100megs Traffic", "100megs Traffic", "http://stats.100mwh.com/cgi-bin/mrtg.cgi");
     
    // Services
    menu.addSubItem("servicesid", "Web Designing", "Web Desigining", "http://www.yaaxy.com");
    menu.addSubItem("servicesid", "Weather", "Weather", "http://www.weather.com");
     
    menu.showMenu();
    }
    Here is the menu.js I dont mess with this to much except to change maybe the fonts or colors

    Code:
    ie=0;
    n=0;
    if (document.all)	{n=0;ie=1;fShow="visible";fHide="hidden";}
    if (document.layers) {n=1;ie=0;fShow="show"; fHide="hide";}
    window.onerror=new Function("return true")
    ////////////////////////////////////////////////////////////////////////////
    // Function Menu()														//
    ////////////////////////////////////////////////////////////////////////////
    rightX = 0;
    function Menu()
    {
    this.bgColor	 = "black";
    if (ie) this.menuFont = "bold xx-small Verdana";
    if (n) this.menuFont = "bold x-small Verdana";
    // this.fontColor = "white";
    		tableWidth = '100%';
    this.addItem	= addItem;
    this.addSubItem = addSubItem;
    this.showMenu = showMenu;
    this.mainPaneBorder = 0;
    this.subMenuPaneBorder = 0;
    this.subMenuPaneWidth = 110;
    lastMenu = null;
     
    rightY = 0;
    leftY = 0;
    leftX = 0;
    HTMLstr = "";
    HTMLstr += "<!-- MENU PANE DECLARATION BEGINS -->\n";
    HTMLstr += "\n";
    if (ie) HTMLstr += "<div id='MainTable' style='position:relative'>\n";
    // if (n) HTMLstr += "<layer name='MainTable'>\n";
    HTMLstr += "<table width="+tableWidth+" bgcolor='"+this.bgColor+"' border='"+this.mainPaneBorder+"'>\n";
    HTMLstr += "<tr>";
    if (n) HTMLstr += "<td>&nbsp;";
    HTMLstr += "<!-- MAIN MENU STARTS -->\n";
    HTMLstr += "<!-- MAIN_MENU -->\n";
    HTMLstr += "<!-- MAIN MENU ENDS -->\n";
    if (n) HTMLstr += "</td>";
    		HTMLstr += "<td width=30%><p align=right><small><small><small><font face=Arial color=white>(c) 1998 - 2001, DigiMasters Inc.</font></small></small></small></p></td>";
    HTMLstr += "</tr>\n";
    HTMLstr += "</table>\n";
    HTMLstr += "\n";
    HTMLstr += "<!-- SUB MENU STARTS -->\n";
    HTMLstr += "<!-- SUB_MENU -->\n";
    HTMLstr += "<!-- SUB MENU ENDS -->\n";
    HTMLstr += "\n";
    if (ie) HTMLstr+= "</div>\n";
    // if (n) HTMLstr+= "</layer>\n";
    HTMLstr += "<!-- MENU PANE DECALARATION ENDS -->\n";
    }
    function addItem(idItem, text, hint, location, altLocation)
    {
    var Lookup = "<!-- ITEM "+idItem+" -->";
    if (HTMLstr.indexOf(Lookup) != -1)
    {
    alert(idParent + " already exist");
    return;
    }
    var MENUitem = "";
    MENUitem += "\n<!-- ITEM "+idItem+" -->\n";
    if (n)
    {
    MENUitem += "<ilayer name="+idItem+">";
    MENUitem += "<font color=white>|</font><a href='.' class=clsMenuItemNS onmouseover=\"displaySubMenu('"+idItem+"')\" onclick=\"return false;\">";
    MENUitem += "&nbsp;";
    MENUitem += text;
    MENUitem += "</a>";
    MENUitem += "</ilayer>";
    }
    if (ie)
    {
    MENUitem += "<td>\n";
    MENUitem += "<div id='"+idItem+"' style='position:relative; font: "+this.menuFont+";'>\n";
    MENUitem += "<font color=white>|</font><a ";
    MENUitem += "class=clsMenuItemIE ";
    MENUitem += "style='text-decoration: none; font: "+this.menuFont+"; color: "+this.fontColor+"; cursor: hand;' ";
    if (hint != null)
    MENUitem += "title='"+hint+"' ";
    if (location != null)
    {
    MENUitem += "href='"+location+"' ";
    MENUitem += "onmouseover=\"hideAll()\" ";
    }
    else
    {
    if (altLocation != null)
    	MENUitem += "href='"+altLocation+"' ";
    else
    						{
    	MENUitem += "href='.' ";
    	MENUitem += "onclick=\"return false;\" "
    						}
    MENUitem += "onmouseover=\"displaySubMenu('"+idItem+"')\" ";
    }
    MENUitem += ">";
    MENUitem += "&nbsp;\n";
    MENUitem += text;
    MENUitem += "</a>\n";
    MENUitem += "</div>\n";
    MENUitem += "</td>\n";
    }
    MENUitem += "<!-- END OF ITEM "+idItem+" -->\n\n";
    MENUitem += "<!-- MAIN_MENU -->\n";
    HTMLstr = HTMLstr.replace("<!-- MAIN_MENU -->\n", MENUitem);
    }
    function addSubItem(idParent, text, hint, location)
    {
    var MENUitem = "";
    Lookup = "<!-- ITEM "+idParent+" -->";
    if (HTMLstr.indexOf(Lookup) == -1)
    {
    alert(idParent + " not found");
    return;
    }
    Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->";
    if (HTMLstr.indexOf(Lookup) == -1)
    {
    if (n)
    {
    MENUitem += "\n";
    MENUitem += "<layer id='"+idParent+"submenu' visibility=hide bgcolor='"+this.bgColor+"'>\n";
    MENUitem += "<table border='"+this.subMenuPaneBorder+"' bgcolor='"+this.bgColor+"' width="+this.subMenuPaneWidth+">\n";
    MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
    MENUitem += "</table>\n";
    MENUitem += "</layer>\n";
    MENUitem += "\n";
    }
    if (ie)
    {
    MENUitem += "\n";
    MENUitem += "<div id='"+idParent+"submenu' style='position:absolute; visibility: hidden; width: "+this.subMenuPaneWidth+"; font: "+this.menuFont+"; top: -300;'>\n";
    MENUitem += "<table border='"+this.subMenuPaneBorder+"' bgcolor='"+this.bgColor+"' width="+this.subMenuPaneWidth+">\n";
    MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
    MENUitem += "</table>\n";
    MENUitem += "</div>\n";
    MENUitem += "\n";
    }
    MENUitem += "<!-- SUB_MENU -->\n";
    HTMLstr = HTMLstr.replace("<!-- SUB_MENU -->\n", MENUitem);
    }
    Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
    if (n) MENUitem = "<tr><td><a class=clsMenuItemNS title='"+hint+"' href='"+location+"'>"+text+"</a><br></td></tr>\n";
    if (ie) MENUitem = "<tr><td><a class=clsMenuItemIE title='"+hint+"' href='"+location+"'>"+text+"</a><br></td></tr>\n";
    MENUitem += Lookup;
    HTMLstr = HTMLstr.replace(Lookup, MENUitem);
    }
    function showMenu()
    {
    document.writeln(HTMLstr);
    }
    ////////////////////////////////////////////////////////////////////////////
    // Private declaration
    function displaySubMenu(idMainMenu)
    {
    var menu;
    var submenu;
    if (n)
    {
    submenu = document.layers[idMainMenu+"submenu"];
    if (lastMenu != null && lastMenu != submenu) hideAll();
    submenu.left = document.layers[idMainMenu].pageX;
    submenu.top = document.layers[idMainMenu].pageY + 21;
    submenu.visibility = fShow;
    leftX = document.layers[idMainMenu+"submenu"].left;
    rightX = leftX + document.layers[idMainMenu+"submenu"].clip.width;
    leftY = document.layers[idMainMenu+"submenu"].top+
    document.layers[idMainMenu+"submenu"].clip.height;
    rightY = leftY;
    } else if (ie) {
    menu = eval(idMainMenu);
    submenu = eval(idMainMenu+"submenu.style");
    submenu.left = calculateSumOffset(menu, 'offsetLeft') + 2;
    // submenu.top = calculateSumOffset(menu, 'offsetTop') + 19;
    submenu.top = menu.style.top + 19;
    submenu.visibility = fShow;
    if (lastMenu != null && lastMenu != submenu) hideAll();
    leftX = document.all[idMainMenu+"submenu"].style.posLeft;
    rightX = leftX + document.all[idMainMenu+"submenu"].offsetWidth;
    leftY = document.all[idMainMenu+"submenu"].style.posTop +
    document.all[idMainMenu+"submenu"].offsetHeight + 74;
    rightY = leftY;
    }
    lastMenu = submenu;
    }
    function hideAll()
    {
    if (lastMenu != null) {lastMenu.visibility = fHide;lastMenu.left = 0;}
    }
    function calculateSumOffset(idItem, offsetName)
    {
    var totalOffset = 0;
    var item = eval('idItem');
    do
    {
    totalOffset += eval('item.'+offsetName);
    item = eval('item.offsetParent');
    } while (item != null);
    return totalOffset;
    }
    function updateIt(e)
    {
    if (ie)
    {
    var x = window.event.clientX;
    var y = window.event.clientY;
    if (x > rightX || x < leftX) hideAll();
    else if (y > rightY || y < 0) hideAll();
    }
    if (n)
    {
    var x = e.pageX;
    var y = e.pageY;
    if (x > rightX || x < leftX) hideAll();
    else if (y > rightY) hideAll();
    }
    }
    if (document.all)
    {
    document.body.onclick=hideAll;
    document.body.onscroll=hideAll;
    document.body.onmousemove=updateIt;
    }
    if (document.layers)
    {
    document.onmousedown=hideAll;
    window.captureEvents(Event.MOUSEMOVE);
    window.onmousemove=updateIt;
    }
    Thanks

  6. #6
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Too much to digest quickly, but could be a problem with the quotes. Try this:
    Code:
    menu.addItem("homeid", "Home", "Home", "javascript&#58;void fn_openPopup(\"http://stlhosting.com\")", null);
    ::: certified wild guess :::

  7. #7
    SitePoint Member
    Join Date
    Aug 2002
    Location
    St. Louis, Mo
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    same thing, blank page

  8. #8
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem with menu scripts is...there's a lot of code; any small error could break the script. We can't run what you posted, as it's incomplete (I understand the difficulty in posting the entire thing).

    Try this:
    Code:
    menu.addItem("homeid", "Home", "Home", "javascript&#58;alert(\"http://stlhosting.com\")", null);
    See what happens...if you don't have JS error reporting turned on (IE: Tools>Internet Options>Advanced>Display a Notification..), do it.
    ::: certified wild guess :::

  9. #9
    SitePoint Member
    Join Date
    Aug 2002
    Location
    St. Louis, Mo
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    weird, nothing, samething I have error displays turned on but no error is given

    I zipped the scripts up http://www.stlhosting.com/menuscript.tar if you want to download them and look at them locally

  10. #10
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DigiCrime...do yourself a favor and...try another menu. That one is ancient; it supports IE4+ and - honestly - Netscape 4. No others. Lots of old, junk code. Many better ones around these days, try -

    http://simplythebest.net/info/dhtml_menu_scripts.html
    http://www.dynamicdrive.com/dynamicindex1/index.html
    ::: certified wild guess :::


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •