Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1031000 // hjs_handleScrollToAnchor - handles an anchor like "#scrollTo123"

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2918L/17K).

// needs JQuery
sS hjs_handleScrollToAnchor() {
  ret hjs([[
    $(window).on("load", function() {
      var anchor = window.location.hash.substr(1);
      var match = anchor.match(/^scrollTo(\d+)$/);
      if (match) {
        var y = parseInt(match[1]);
        console.log("Scrolling to " + y);
        window.scrollTo(0, y);
      }
    });
  ]]);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031000
Snippet name: hjs_handleScrollToAnchor - handles an anchor like "#scrollTo123"
Eternal ID of this version: #1031000/6
Text MD5: 9976b3d29ec0d55f90f6ab8086924a6f
Transpilation MD5: b65d3ef10658eee5be74209d3a4ae07e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-19 16:22:26
Source code size: 366 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 160 / 238
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)