PDA

View Full Version : Dynamic FX-Slide in Menu



mjunior
02-21-2007, 03:55 PM
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();

jscheuer1
02-21-2007, 04:42 PM
Remember, you are firing a link so, you need to use the void() convention:


ssmItems[1]=["Dynamic Drive", "javascript:void(test())", ""]


<!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.

mjunior
02-22-2007, 07:58 PM
Sorry but i keep getting error message "Object awaited"..

mjunior
02-22-2007, 08:03 PM
Within the page, I use this function to load pages on my DIV tag:
ajaxpage(stringObject.toString(),'contentarea')

The ajaxpage 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...

mjunior
02-22-2007, 08:17 PM
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)...

jscheuer1
02-23-2007, 06:05 AM
You may (should actually) be able to have it as an external .js file though.