No edit summary |
Add section-redirect scroll fix (personal test) Tag: Reverted |
||
| Line 3: | Line 3: | ||
mw.loader.load( 'ext.gadget.Twinkle' ); | mw.loader.load( 'ext.gadget.Twinkle' ); | ||
mw.loader.load( 'ext.gadget.BharatMitra' ); | mw.loader.load( 'ext.gadget.BharatMitra' ); | ||
/* Section wale redirect par seedha usi section tak scroll */ | |||
$(function () { | |||
if (window.location.hash) return; | |||
if (!mw.config.get('wgRedirectedFrom')) return; | |||
var link = document.querySelector('link[rel="canonical"]'); | |||
if (!link) return; | |||
var href = link.getAttribute('href') || ''; | |||
var i = href.indexOf('#'); | |||
if (i < 0) return; | |||
var id = decodeURIComponent(href.substring(i + 1)); | |||
var el = document.getElementById(id); | |||
if (!el) return; | |||
history.replaceState(null, '', '#' + id); | |||
el.scrollIntoView(); | |||
}); | |||
Revision as of 09:27, 4 November 2026
mw.loader.load('/w/index.php?title=User:WikiDwarf/AntiVandal.js&action=raw&ctype=text/javascript');
mw.loader.load('https://en.bharatpedia.org/w/index.php?title=MediaWiki:Gadget-OneClickArchiver.js&action=raw&ctype=text/javascript&maxage=0&smaxage=0&t=' + Date.now());
mw.loader.load( 'ext.gadget.Twinkle' );
mw.loader.load( 'ext.gadget.BharatMitra' );
/* Section wale redirect par seedha usi section tak scroll */
$(function () {
if (window.location.hash) return;
if (!mw.config.get('wgRedirectedFrom')) return;
var link = document.querySelector('link[rel="canonical"]');
if (!link) return;
var href = link.getAttribute('href') || '';
var i = href.indexOf('#');
if (i < 0) return;
var id = decodeURIComponent(href.substring(i + 1));
var el = document.getElementById(id);
if (!el) return;
history.replaceState(null, '', '#' + id);
el.scrollIntoView();
});