Looking for help with javascript: void(0)

General questions relating to Joomla! 2.5. Note: All 1.6 and 1.7 releases have reached end of life and should be updated to 2.5. There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
maxbrad124
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sat Sep 18, 2010 2:07 pm

Looking for help with javascript: void(0)

Postby maxbrad124 » Thu Nov 24, 2011 8:36 pm

I have created a number of items in the main menu of my site that im not looking to link anywhere, they are merely there as a kind of header for the sub-menu.

In Joomla 1.7 the only thing I can see to use as the menu's type is 'text separator' but when hovering over the menu item you see that it is linked to 'javascript: void(0)'. In Joomla 1.5 you could select the type 'separator' for this and everything would work fine.

I can see the following tag around the menu item:

Code: Select all

<a href="javascript: void(0)">


How would I go about removing this?

User avatar
bigbangireland
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 154
Joined: Tue Oct 04, 2011 2:26 pm
Location: Dublin, Ireland
Contact:

Re: Looking for help with javascript: void(0)

Postby bigbangireland » Thu Nov 24, 2011 8:52 pm

You could try "External URL" and entering # in the link field.

maxbrad124
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sat Sep 18, 2010 2:07 pm

Re: Looking for help with javascript: void(0)

Postby maxbrad124 » Thu Nov 24, 2011 8:57 pm

Thanks, that's gotten rid of the javascript link but, if its possible, I would prefer it not to link anywhere at all.

User avatar
bigbangireland
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 154
Joined: Tue Oct 04, 2011 2:26 pm
Location: Dublin, Ireland
Contact:

Re: Looking for help with javascript: void(0)

Postby bigbangireland » Thu Nov 24, 2011 9:28 pm

Very strange, I just tried separator it and it works fine.

Are you using a 3rd party module for your menu or a template that overrides the core mod_menu?

Is there a folder here?
/templates/YOUR_TEMPLATE/html/mod_menu/

maxbrad124
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sat Sep 18, 2010 2:07 pm

Re: Looking for help with javascript: void(0)

Postby maxbrad124 » Thu Nov 24, 2011 9:38 pm

Yeah, im using the Jsn Epic template. There are 4 files in that folder:

default.php
default_component.php
default_separator.php
default_url.php

The default_separator.php file has this in it:

Code: Select all

<a href="javascript: void(0)">
   <span>
      <?php          
      if ($item->anchor_title) {
         echo '<span class="jsn-menutitle">'.$linktype.'</span>';
         echo '<span class="jsn-menudescription">'.$item->anchor_title.'</span>';      
      } else {
         echo $linktype;
      }
      ?>
   </span>
  </a>


I have tried to remove the <a> tag but it breaks the whole menu...

User avatar
bigbangireland
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 154
Joined: Tue Oct 04, 2011 2:26 pm
Location: Dublin, Ireland
Contact:

Re: Looking for help with javascript: void(0)

Postby bigbangireland » Thu Nov 24, 2011 9:48 pm

Sorted then, just remove these lines in default_separator.php

Code: Select all

<a href="javascript: void(0)">

</a>


Then test your menu. Depending on the CSS and JS used in the template it may fail.

maxbrad124
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sat Sep 18, 2010 2:07 pm

Re: Looking for help with javascript: void(0)

Postby maxbrad124 » Thu Nov 24, 2011 9:52 pm

I changed
<a href="javascript: void(0)">
to
<a onmouseover="this.style.cursor='pointer'">


The item's aren't showing up as links any more! Thanks for your help :)

User avatar
bigbangireland
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 154
Joined: Tue Oct 04, 2011 2:26 pm
Location: Dublin, Ireland
Contact:

Re: Looking for help with javascript: void(0)

Postby bigbangireland » Thu Nov 24, 2011 9:59 pm

That's no better than how it was. An anchor needs a href to be valid.

Delete the link and add this to the existing span.

Code: Select all

<span style="cursor:pointer">


Or better yet add the CSS externally.

Code: Select all

#menu-id span {
  cursor:pointer
}

Ameenaazeez
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Nov 03, 2017 3:40 am

Re: Looking for help with javascript: void(0)

Postby Ameenaazeez » Fri Nov 03, 2017 3:48 am

Hi maxbrad124 , the error you are getting is not a critical error, but certainly is frustrating. The problem may be lying within your internet browser. I would suggest you to follow the steps given in the website, https://appuals.com/solved-javascriptvoid0/. Hope it helps you out and many others.


Return to “General Questions/New to Joomla! 2.5”

Who is online

Users browsing this forum: No registered users and 4 guests