SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    can you put javascript within javascript?

    I have an image map that when you mouseover one area a popup menu displays that I created in dreamweaver.
    Now besides the popout menu displaying when someone does a mouseover on one of the popout menu items, I want a simple text caption to display or could I even use another popout menu? I tried putting in a simple pop out function and it caused both javascripts to error.
    Below is a sample of the javascript that I think is wrong.
    Code:
    <script language="JavaScript" type="text/JavaScript">
    
    function url(url) {
        window.status = url;
    }
    
    function over(text,url) {
        window.status = text;
        return true;
    }
    
    function out() {
        window.status = '';
        return true;
    }
    window.mm_menu_0803125437_0 = new Menu("root",50,18,"Verdana, Arial, Helvetica, sans-serif",6,"#FFFFFF","#000066","#000066","#FFFFFF","center","middle",3,0,1000,-5,7,true,true,true,0,true,true);
      <cfset thecnt = 0>
    <cfloop query='getS8'>
    <cfoutput>
    <cfset #thecnt# = #thecnt# + 1>
      mm_menu_0803125437_0.addMenuItem("#unitname#","location='preview.cfm?id=#id#&mainunitid=#Property_ID#<cfif parameterexists(unitname)>&unitname=#unitname#</cfif> onMouseOver="return over('some status text',this.location)" onMouseOut="return out()"'");    </cfoutput>
    </cfloop>
       mm_menu_0803125437_0.fontWeight="bold";
       mm_menu_0803125437_0.hideOnMouseOut=true;
       mm_menu_0803125437_0.bgColor='#999999';
       mm_menu_0803125437_0.menuBorder=1;
       mm_menu_0803125437_0.menuLiteBgColor='#FFFFFF';
       mm_menu_0803125437_0.menuBorderBgColor='#000066';
    
    mm_menu_0803125437_0.writeMenus();
    } // mmLoadMenus()
    The mouseovers in the body are correct. How would I be able to get the second pop out to appear?

  2. #2
    SitePoint Guru Chroniclemaster1's Avatar
    Join Date
    Jun 2007
    Location
    San Diego, CA
    Posts
    784
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think you can call a Javascript function inside of Javascript code... OK, let me be more honest, I don't know how. I think what you have to do is use the first script to open the first menu like you're doing.

    Then maybe add an event listener to watch for whatever event you want (like mousing over a selection on the first menu). Then it would be the event listener calling the second Javascript function, and I think you could get away with it. In fact, you may only have to call the same menu function again (simply passing in the new parameters for the second menu).


    Hope that helps.
    Whatever you can do or dream you can, begin it.
    Boldness has genius, power and magic in it. Begin it now.

    Chroniclemaster1, Founder of Earth Chronicle
    A Growing History of our Planet, by our Planet, for our Planet.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, what you are saying makes sense, but I have no idea what an event listener is. Any suggestions on how to get started?

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Location
    Bel Air, Maryland.
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An event listener will sort of watch the document for a certain event (like mouseover or click) to occur on a specified object. It's a DOM alternative to the onclick or onmouseover methods.

    Heres a random tutorial I found
    http://www.lowter.com/article/too-easy-javascript-7
    ---
    Paul S. Smith
    technetic | design & code


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
  •