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

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesJavaScript in DNNJavaScript in DNN
Previous
 
Next
New Post
2/26/2012 2:24 AM
 

Hello people,

I am trying to run this javascript for tab browsing. Although I created a sample javascript for alert and it worked fine but this code isn't executing. I know we gotta write the code in Advance Setting > header / Footer .. please lemme know the error

 

<script type="text/javascript">

    var tabLinks = new Array();
    var contentDivs = new Array();

    function init() {

      // Grab the tab links and content divs from the page
    
 var tabListItems = document.getElementById('tabs').childNodes;
      for ( var i = 0; i < tabListItems.length; i++ ) {

        if ( tabListItems[i].nodeName == "LI" ) {

          var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' );

          var id = getHash( tabLink.getAttribute('href') );

          tabLinks[id] = tabLink;

          contentDivs[id] = document.getElementById( id );
        }
      }

      // Assign onclick events to the tab links, and
      // highlight the first tab

      var i = 0;

      for ( var id in tabLinks ) {

        tabLinks[id].onclick = showTab;
    
   tabLinks[id].onfocus = function() { this.blur() };

        if ( i == 0 ) tabLinks[id].className = 'selected';

        i++;
      }

      // Hide all content divs except the first
      var i = 0;

      for ( var id in contentDivs )
{
        if ( i != 0 ) contentDivs[id].className = 'tabContent hide';
        i++;
      }
    }

    function showTab()
{
      var selectedId = getHash( this.getAttribute('href') );

      // Highlight the selected tab, and dim all others.
      // Also show the selected content div, and hide all others.

      for ( var id in contentDivs )
{
        if ( id == selectedId )
{
          tabLinks[id].className = 'selected';
          contentDivs[id].className = 'tabContent';
        } else {
          tabLinks[id].className = '';
          contentDivs[id].className = 'tabContent hide';
        }
      }

      // Stop the browser following the link
      return false;
    }

    function getFirstChildWithTagName( element, tagName ) {
      for ( var i = 0; i < element.childNodes.length; i++ ) {
if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
      }
    }

    function getHash( url ) {
      var hashPos = url.lastIndexOf ( '#' );
      return url.substring( hashPos + 1 );
    }
 </script>

 
New Post
3/6/2012 12:55 AM
 
Have you considered using jQuery (part of DNN)? It makes writing JS a breeze and produces a lot more readable/manageable code. Thanks

Mandeep Singh
CEO - Mandeeps.com | Developing DotNetNuke Modules Since 2004
DNN Monitor | DotNetNuke Keep Alive Service
 
New Post
3/19/2012 2:32 PM
 
Do you know if there is an example of how to do this? I don't know anything about JQuery and can't figure out how to get into my module.

I am needing to send the user one of 2 alerts depending upon if they click a link to add an item to their dashboard and 1) it doesn't exist yet or 2) it already exists in their dashboard.

Thanks!
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesJavaScript in DNNJavaScript in DNN


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