Template: WhatLinksHere: Difference between revisions
From ASDSO Dam Safety Toolbox
No edit summary Tag: Manual revert |
No edit summary |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<html> | <html> | ||
<div id="iframeDiv" style="display:none;"> | <div id="iframeDiv" style="display:none;"> | ||
<hr style="width:5%;"> | |||
<h4>What links here</h4> | <h4>What links here</h4> | ||
<iframe id="iframeWin" | <iframe id="iframeWin" | ||
src="/wiki/Special:WhatLinksHere/</html>{{PAGENAME}}<html>" | src="/wiki/Special:WhatLinksHere/</html>{{PAGENAME}}<html>" | ||
style="border:none;width:100%; | style="border:none;width:100%;"></iframe> | ||
</div> | </div> | ||
<script> | <script> | ||
document.querySelector("iframe").addEventListener( "load", function(e) { | document.querySelector("iframe").addEventListener( "load", function(e) { | ||
// Add parent to links | |||
let iframeWin = document.getElementById("iframeWin"); | |||
let anchors = iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("a"); | |||
// | for (let i=0; i<anchors.length; i++){ | ||
iframeWin | anchors[i].setAttribute('target', '_parent'); | ||
} | |||
// Show iframe | |||
// Show | |||
document.getElementById('iframeDiv').style.display="block"; | document.getElementById('iframeDiv').style.display="block"; | ||
}); | }); | ||
window.onload = function() { | window.onload = function() { | ||
// Set styles | |||
let iframeStyles = ` | |||
<style> | |||
#maincontentwrapper { | |||
margin-left: 0px; | |||
padding-left: 0px; | |||
} | |||
#content { | |||
padding-top: 0px; | |||
padding-left: 0px; | |||
} | |||
header, #footer, | |||
form, fieldset, | |||
.firstHeading, | |||
#contentSub, | |||
.usermessage, | |||
.mw-htmlform-ooui-wrapper { | |||
display: none; | |||
} | |||
</style>`; | |||
let iframeWin = document.getElementById("iframeWin"); | |||
let doc = iframeWin.contentDocument; | |||
doc.body.innerHTML = doc.body.innerHTML + iframeStyles; | |||
// Set height | // Set height | ||
iframeWin.height = iframeWin.contentWindow.document.body.scrollHeight; | iframeWin.height = iframeWin.contentWindow.document.body.scrollHeight; |
Latest revision as of 15:11, 9 August 2023