Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Javscript inside ascx skin file not workingJavscript inside ascx skin file not working
Previous
 
Next
New Post
7/22/2009 10:15 AM
 

 Hi All,

I'm trying to achieve this functinality given in this forum on my dnn page . http://forums.asp.net/t/1225510.aspx

I have placed a unordered list inside left pane div of my skin.ascx file as below. 

<ul id="TopMenu">

                                          <li><a href="page1.aspx"> page1 </a>

                                                <ul>

                                                    <li><a href="page2.aspx"> page2 </a></li>

                                                    <li><a href="page3.aspx"> page3 </a></li>

                                                    <li><a href="page4.aspx"> page4 </a></li>

                                                </ul>

                                            </li>

                                            <li><a href="#"> page5 </a></li>

                                            <li><a href="#"> page6 </a> </li>

                                           

                                          

                                        </ul>

I need to register a js file for this control and i placed it inside the skin folder and registered it in the following syntax.Is it the right way to do as the javascript is not working?

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Page.ClientScript.RegisterClientScriptInclude("MenuFix", "<%=SkinPath%>menu.js")

    End Sub

The following is the js file.

function menuFix() {

 

    var sfEls = document.getElementById("TopMenu").getElementsByTagName("li");

    for (var i=0; i<sfEls.length; i++) {

        sfEls[i].onclick = function() {

            if(this.className.indexOf("sfhover") < 0)

            {

                //Expend this

                this.className+=(this.className.length>0? " ": "") + "sfhover";

 

                //Close Others

                var sfEls2 = document.getElementById("TopMenu").getElementsByTagName("li");

                for (var i=0; i<sfEls2.length; i++) {

                    if(sfEls2[i].className.indexOf("sfhover") >= 0 && sfEls2[i] != this)

                    {

                        sfEls2[i].className=sfEls2[i].className.replace(new RegExp("( ?|^)sfhover\\b"),"");

                    }

                }

            }

            else

            {

                this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),"");

            }

        }

    }

}

window.onload=menuFix;

Where do i need to call the function menuFix in order for it to get working in the ascx file. Shoud it be window.onload?

Can anybody please tell me what is the mistake being done here.

Thanks in advance.

-sri

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Javscript inside ascx skin file not workingJavscript inside ascx skin file not working


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out