Results 1 to 6 of 6

Thread: Dynamic FX-Slide in Menu

  1. #1
    Join Date
    Apr 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dynamic FX-Slide in Menu

    http://www.dynamicdrive.com/dynamicindex1/davidmenu.htm

    Does anyone knows how to use the ssmItens.js script to load pages in a div instead of new page?

    I'm using server side include to insert the two js files from this slide menu into my main page and that's work fine. But afterwards, I can't call any function from my main page in order to load the href inside a div, and keep getting null or unexistense object errors when trying to reiffer to any element on my main page.
    Even a simple function like test(){alert("test")} can't be called within the menu...

    // ssmItems[...]=[name, link, target, colspan, endrow?] - leave 'link' and 'target' blank to make a header
    ssmItems[0]=["Test"] //create header
    ssmItems[1]=["Test", "javascript:test();", ""]

    buildMenu();

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Remember, you are firing a link so, you need to use the void() convention:

    Code:
    ssmItems[1]=["Dynamic Drive", "javascript:void(test())", ""]
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    A.ssmItems:link		{color:black;text-decoration:none;}
    A.ssmItems:hover	{color:black;text-decoration:none;}
    A.ssmItems:active	{color:black;text-decoration:none;}
    A.ssmItems:visited	{color:black;text-decoration:none;}
    //-->
    </style>
    
    <SCRIPT SRC="ssm.js" language="JavaScript1.2">
    
    //Dynamic-FX slide in menu v6.5 (By maXimus, http://maximus.ravecore.com/)
    //Updated July 8th, 03' for doctype bug
    //For full source, and 100's more DHTML scripts, visit http://www.dynamicdrive.com
    
    </SCRIPT>
    
    <SCRIPT SRC="ssmItems.js" language="JavaScript1.2"></SCRIPT>
    <script type="text/javascript">
    function test(){
    alert('hi');
    }
    </script>
    </head>
    <body>
    
    </body>
    </html>
    This may cause problems in some IE versions though but, you won't know until you try. Worked fine here in IE 7.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry but i keep getting error message "Object awaited"..

  4. #4
    Join Date
    Apr 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Within the page, I use this function to load pages on my DIV tag:
    ajaxpage(stringObject.toString(),'contentarea')

    The ajaxpage code:
    HTML Code:
    var bustcachevar=1 
    var loadedobjects=""
    var rootdomain="http://"+window.location.hostname
    var bustcacheparameter=""
    
    function ajaxpage(url, containerid){
    var page_request = false
    if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (window.ActiveXObject){ // if IE
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP")
    } 
    catch (e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch (e){}
    }
    }
    else
    return false
    page_request.onreadystatechange=function(){
    loadpage(page_request, containerid)
    }
    if (bustcachevar) //if bust caching of external page
    bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
    page_request.open('GET', url+bustcacheparameter, true)
    page_request.send(null)
    }
    
    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(containerid).innerHTML=page_request.responseText
    }
    
    function loadobjs(){
    if (!document.getElementById)
    return
    for (i=0; i<arguments.length; i++){
    var file=arguments[i]
    var fileref=""
    if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
    if (file.indexOf(".js")!=-1){ //If object is a js file
    fileref=document.createElement('script')
    fileref.setAttribute("type","text/javascript");
    fileref.setAttribute("src", file);
    }
    else if (file.indexOf(".css")!=-1){ //If object is a css file
    fileref=document.createElement("link")
    fileref.setAttribute("rel", "stylesheet");
    fileref.setAttribute("type", "text/css");
    fileref.setAttribute("href", file);
    }
    }
    if (fileref!=""){
    document.getElementsByTagName("head").item(0).appendChild(fileref)
    loadedobjects+=file+" " //Remember this object as being already added to page
    }
    }
    }
    But using the slide menu, somehow I lost contact with this dunction and whatever other object on my main page...

  5. #5
    Join Date
    Apr 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Doing more tests, I realize I could reach the test function only when I place it on main page and not on loaded page or neither on my include page (slide menu page)...

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You may (should actually) be able to have it as an external .js file though.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •