Javascript not working on my Yolasite?

  • 1
  • Question
  • Updated 9 years ago
  • Answered
I just added the following Java-Script [from "www.javascript-array.com", which the users have seen results] into my yolasite.

"// Copyright 2006-2007 javascript-array.com

var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

// open hidden layer
function mopen(id)
{
// cancel close timer
mcancelclosetime();

// close old layer
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

// get new layer and show it
ddmenuitem = document.getElementById(id);
ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
if(closetimer)
{
window.clearTimeout(closetimer);
closetimer = null;
}
}

// close layer when click-out
document.onclick = mclose;
"

When I publish my site, it looks as if I have entered some text, and the intended menu does not show up. Following image shows the view I get:

Photo of UdaraW

UdaraW

  • 2 Posts
  • 0 Reply Likes
  • frustrated

Posted 9 years ago

  • 1
Photo of Kershnee

Kershnee

  • 2087 Posts
  • 152 Reply Likes
Hi There,

The reason you are having this issue is because you are missing the script tags from your code. Here's what you need to do:
add <script> to the start of your code and </script> to the end of your code.

<script>
your code
</script>