Hi. I have a JS code that does a flyout menu. My problem is that it only works for a menu which is on the left side and expands on the right. But I want it to work the other way too.
The menu can be found here: http://www.javascrip...ticalmenu.shtml.
I know that if I change the this.getElementsByTagName("ul")[0].style.left=this.parentNode.offsetWidth+submenuoffset+"px" code into this.getElementsByTagName("ul")[0].style.right=this.parentNode.offsetWidth+submenuoffset+"px" and something in the CSS file, it works. My problem is, how do I make an IF statement which checks which menu it is? Note: the var menuids=new Array("verticalmenu") code can have more menus, which is in my case. I want the code to be this.getElementsByTagName("ul")[0].style.left=this.parentNode.offsetWidth+submenuoffset+"px" when the 'verticalmenu' is displayed and the this.getElementsByTagName("ul")[0].style.right=this.parentNode.offsetWidth+submenuoffset+"px" code when the 'verticalmenu2' is displayed.
O hope it's clear enough.
Thank you.
Modify an existing script
Page 1 of 13 Replies - 1894 Views - Last Post: 27 September 2008 - 01:45 AM
Replies To: Modify an existing script
#2
Re: Modify an existing script
Posted 19 September 2008 - 01:54 PM
I copied the javascript from the link you mentioned
original
Change to
original
function createcssmenu(){
for (var i=0; i<menuids.length; i++){
var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
for (var t=0; t<ultags.length; t++){
var spanref=document.createElement("span")
spanref.className="arrowdiv"
spanref.innerHTML=" "
ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
ultags[t].parentNode.onmouseover=function(){
this.getElementsByTagName("ul")[0].style.left=this.parentNode.offsetWidth+submenuoffset+"px"
this.getElementsByTagName("ul")[0].style.display="block"
}
ultags[t].parentNode.onmouseout=function(){
this.getElementsByTagName("ul")[0].style.display="none"
}
}
}
}
Change to
function createcssmenu(){
for (var i=0; i<menuids.length; i++){
var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
for (var t=0; t<ultags.length; t++){
var spanref=document.createElement("span")
spanref.className="arrowdiv"
spanref.innerHTML=" "
ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
ultags[t].parentNode.onmouseover=function(){
if(this.id=="verticalmenu"){
this.getElementsByTagName("ul")[0].style.left=this.parentNode.offsetWidth+submenuoffset+"px"
}
else {
this.getElementsByTagName("ul")[0].style.right=this.parentNode.offsetWidth+submenuoffset+"px"
}
this.getElementsByTagName("ul")[0].style.display="block"
}
ultags[t].parentNode.onmouseout=function(){
this.getElementsByTagName("ul")[0].style.display="none"
}
}
}
}
This post has been edited by mocker: 19 September 2008 - 01:55 PM
#3
Re: Modify an existing script
Posted 19 September 2008 - 01:58 PM
That doesn't work either. Idk why... I have tried something else... something like if(menuids[i]=="verticalmenu") ... else ... but that didn't work either... isn't there a method to output this.id or menuids[i]?
EDIT: the code was OK, both mine and yours, the CSS wasn't
Thank you very much.
EDIT: the code was OK, both mine and yours, the CSS wasn't
This post has been edited by edu2004eu: 19 September 2008 - 02:28 PM
#4
Re: Modify an existing script
Posted 27 September 2008 - 01:45 AM
dear frens.... i need some advice on how to put an image within the alert box.... 2nd alert box i must say....
thank you.
<script language="Javascript">
<!-----hide from old browsers
alert('HIGHLY RESTRICTED AREA!');
//--------->
</SCRIPT>
<script LANGUAGE="Javascript">
<!-- Begin
var agree = confirm("VIOLATION OF THIS SYSTEM WILL RESULT TO THE LAW OF XXXXXXX. ANY UNAUTHORIZED ACCESS IS PROHIBITED");
if (agree)
document.write("");
else
history.go(-1);
// End -->
</SCRIPT>
thank you.
<script language="Javascript">
<!-----hide from old browsers
alert('HIGHLY RESTRICTED AREA!');
//--------->
</SCRIPT>
<script LANGUAGE="Javascript">
<!-- Begin
var agree = confirm("VIOLATION OF THIS SYSTEM WILL RESULT TO THE LAW OF XXXXXXX. ANY UNAUTHORIZED ACCESS IS PROHIBITED");
if (agree)
document.write("");
else
history.go(-1);
// End -->
</SCRIPT>
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|