Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 ------, ------

views
     
TSaveragehumanbeing
post Jan 23 2016, 07:42 PM, updated 9y ago

Getting Started
**
Junior Member
51 posts

Joined: Apr 2015
From: Utah, US of A
This post has been overwritten by a script.

This post has been edited by averagehumanbeing: Jul 21 2017, 07:14 AM
ChaoGuGu
post Jan 23 2016, 07:58 PM

Getting Started
**
Junior Member
138 posts

Joined: Jun 2008
You saying your code will works if the link shows "http://google.com/index.html#projects" ?


TSaveragehumanbeing
post Jan 23 2016, 08:04 PM

Getting Started
**
Junior Member
51 posts

Joined: Apr 2015
From: Utah, US of A
This post has been overwritten by a script.

This post has been edited by averagehumanbeing: Jul 21 2017, 07:14 AM
ChaoGuGu
post Jan 23 2016, 08:08 PM

Getting Started
**
Junior Member
138 posts

Joined: Jun 2008
Probably you did not set the href on the anchor. Redirection using script will not show the hyperlink when you hover.

As what you trying to achieve. Your code is quite redundant because you loop over all the anchors whenever you scroll lol. You can append custom data to any tags and you can use jquery to retrieve the custom data. So you might want to use the custom data to the functions you need.

Edit : right client on chrome and you can use the basic client script cheker. You should see the red line that is causing the error. Of course it's very simple troubleshooting feature unlike vbs.

This post has been edited by ChaoGuGu: Jan 23 2016, 08:15 PM
Fork
post Jan 23 2016, 08:10 PM

Getting Started
**
Junior Member
157 posts

Joined: Sep 2010
href is empty?

u should use anchors that are not related to ur element id, then use location.hash value to find the element in ur document.

example:

index.php#home

ur element's id should be id="page-home", then use javascript to find the element "page-"+location.hash and scroll to that element
regnessem
post Jan 23 2016, 08:25 PM

Casual
***
Junior Member
398 posts

Joined: Dec 2013


Why is this in /k & not in https://forum.lowyat.net/Codemasters shocking.gif
angeldothack
post Jan 23 2016, 08:28 PM

Ore.?
******
Senior Member
1,072 posts

Joined: Jan 2003
From: 8 5 0 0 0


Try this one?

CODE
(function() {
var delay = false;

$(document).on('mousewheel DOMMouseScroll', function(event) {
  event.preventDefault();
  if(delay) return;

  delay = true;
  setTimeout(function(){delay = false},200)

  var wd = event.originalEvent.wheelDelta || -event.originalEvent.detail;

  var a= document.getElementsByTagName('a');
  if(wd < 0) {
    for(var i = 0; i < a.length; i++) {
      var t = a[i].getClientRects()[0].top;
      if(t >= 40) break;
    }
  }
  else {
    for(var i = a.length-1; i >= 0; i--) {
      var t = a[i].getClientRects()[0].top;
      if(t < -20) break;
    }
  }

  if (typeof a[i] != 'undefined') {
    $('html,body').animate({
         scrollTop: a[i].offsetTop
    });
    var href = $.attr(a[i], 'name');
    window.location.hash = href;
  } else {
    history.pushState("", document.title, window.location.pathname + window.location.search);
  }
});
})();


 

Change to:
| Lo-Fi Version
0.0120sec    0.78    5 queries    GZIP Disabled
Time is now: 16th December 2025 - 02:25 PM