Title: [Theme: OneEngine] menu javascript problem
Last modified: August 22, 2016

---

# [Theme: OneEngine] menu javascript problem

 *  [CAhlback](https://wordpress.org/support/users/cahlback/)
 * (@cahlback)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/oneengine-menu-javascript-problem/)
 * Hey there!
    So, I’m using the OneEngine theme, since I like how I can create 
   one-page templates with it. I do miss a better parallax function (this gives 
   me a fixated parallax background, I would like a slower-moving background). However,
   to the actual topic! (I might create another topic for the parallax thing)
 * This theme is one-page. It implies that other pages won’t get the head menu. 
   I changed that in the header.
 * The menu is pretty cool, since clicking on a #hash link takes me to the section
   in the page with a scroll.to. Nice.
 * The problem is that I realized that the menu really is for the one-page-theme
   only. External links, or links to other pages on the site really does nothing.
   Something in the menu-script stops that.
 * However, that was fixed with a fix I found. So now external links work. However,
   it really doesn’t work properly yet.
 * The problem is that url’s with a hash tag only works on the page the hash tag
   links to. On any other page, the link is dead.
 * I might know why, but I really do now know how to get a work-around for this.
   I know there’s some window.location.hash stuff I could use, but I don’t know 
   how..
 *     ```
       // SCROLL TO
       $('#main-menu-top a,ul.slicknav_nav li a').click(function(event){
       if( this.hash.indexOf("#") < 0 )
       return true;
   
       event.stopPropagation();
       event.preventDefault();
   
       //If there's no hash tag, the function above returnes TRUE,
       //and the script will (somehow) skip the rest, and any link
       //without a hash tag will work (which it didn't in the original script).
       //It will simply work as an ordinary link.
       //If there's a hash tag and we're on that very page, it will scroll to that.
       //However, if we're on another page within the site, and the link contains a hash tag,
       //nothing will happen.
       //This code needs to become so that every typ of link works.
       //Links to other sites or other pages, and links with hashtag in the beginning or the end.
       //Since I will have multiple pages, I need the links to contain both the url and the hash.
   
       		if($(this).hasClass('active'))
       			return;
   
       		$('#main-menu-top a').removeClass('active').css('border-bottom-color', 'none');
       		$(this).addClass('active');
   
       		if(this.hash == "#home")
       			$.scrollTo(0,800);
       		else
       			$.scrollTo( this.hash, 800, {offset:-$(".sticky-wrapper").height()});
   
       		var bgcolor = $(this.hash).find('span.line-title').css('backgroundColor');
       		$(this).css('border-bottom-color', bgcolor);
   
       		$('.slicknav_nav').hide('normal', function() {
       			$(this).addClass('slicknav_hidden');
       		});
       		$('a.slicknav_btn').removeClass('slicknav_open').addClass('slicknav_collapsed');
   
       		return false;
       	});
       	$("a#scroll_to").click(function(event) {
       		$.scrollTo("#header", 800);
       	});
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [CAhlback](https://wordpress.org/support/users/cahlback/)
 * (@cahlback)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/oneengine-menu-javascript-problem/#post-5565127)
 * edit: better //description in the code.
 *  [nprib](https://wordpress.org/support/users/nprib/)
 * (@nprib)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/oneengine-menu-javascript-problem/#post-5565464)
 * Hi,
 * Thank you for your code copy&paste and it’s ok 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Theme: OneEngine] menu javascript problem’ is closed to new replies.

## Tags

 * [hash](https://wordpress.org/support/topic-tag/hash/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [menu](https://wordpress.org/support/topic-tag/menu/)
 * [oneengine](https://wordpress.org/support/topic-tag/oneengine/)
 * [scroll.to](https://wordpress.org/support/topic-tag/scroll-to/)

 * 2 replies
 * 2 participants
 * Last reply from: [nprib](https://wordpress.org/support/users/nprib/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/oneengine-menu-javascript-problem/#post-5565464)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
