|
|
(5 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| <noinclude>
| |
| == Usage ==
| |
| {{WhatLinksHere}}
| |
|
| |
| <script>
| |
| document.querySelector("iframe").addEventListener( "load", function(e) {
| |
| var iframeWin = document.getElementById("iframeWin");
| |
| var content = (iframeWin.contentWindow || iframeWin.contentDocument);
| |
| if (content.document)content = content.document;
| |
| // Adjust padding/margin
| |
| iframeWin.contentWindow.document.getElementById('maincontentwrapper').style.marginLeft = "0px";
| |
| iframeWin.contentWindow.document.getElementById('maincontentwrapper').style.paddingLeft = "0px";
| |
| // Hide header, heading, back link, special messages, form, filters, and footer
| |
| content.body.getElementsByTagName("header")[0].style.display = "none";
| |
| content.body.getElementsByClassName("firstHeading")[0].style.display = "none";
| |
| iframeWin.contentWindow.document.getElementById('contentSub').style.display = "none";
| |
| iframeWin.contentWindow.document.getElementsByClassName('usermessage')[0].style.display = "none";
| |
| iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("fieldset")[0].style.display = "none";
| |
| iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("fieldset")[1].style.display = "none";
| |
| iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("p")[0].style.display = "none";
| |
| iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("p")[1].style.display = "none";
| |
| content.body.getElementsByTagName("footer")[0].style.display = "none";
| |
| // Add parent to links
| |
| var anchors = iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("a");
| |
| for (var i=0; i<anchors.length; i++){
| |
| anchors[i].setAttribute('target', '_parent');
| |
| }
| |
| // Show
| |
| document.getElementById('iframeDiv').style.display="block";
| |
| });
| |
|
| |
| window.onload = function() {
| |
| var iframeWin = document.getElementById("iframeWin");
| |
| // Set height
| |
| iframeWin.height = iframeWin.contentWindow.document.body.scrollHeight;
| |
| }
| |
| </script>
| |
| </noinclude>
| |
|
| |
|
| |
| ----
| |
| <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> |
| title="What Links Here"></iframe>
| |
| </div> | | </div> |
|
| |
|
| <script> | | <script> |
| document.querySelector("iframe").addEventListener( "load", function(e) { | | document.querySelector("iframe").addEventListener( "load", function(e) { |
| var iframeWin = document.getElementById("iframeWin");
| |
| var content = (iframeWin.contentWindow || iframeWin.contentDocument);
| |
| if (content.document)content = content.document;
| |
| // Adjust padding/margin
| |
| iframeWin.contentWindow.document.getElementById('maincontentwrapper').style.marginLeft = "0px";
| |
| iframeWin.contentWindow.document.getElementById('maincontentwrapper').style.paddingLeft = "0px";
| |
| // Hide header, heading, back link, special messages, form, filters, and footer
| |
| content.body.getElementsByTagName("header")[0].style.display = "none";
| |
| content.body.getElementsByClassName("firstHeading")[0].style.display = "none";
| |
| iframeWin.contentWindow.document.getElementById('contentSub').style.display = "none";
| |
| iframeWin.contentWindow.document.getElementsByClassName('usermessage')[0].style.display = "none";
| |
| iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("fieldset")[0].style.display = "none";
| |
| iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("fieldset")[1].style.display = "none";
| |
| iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("p")[0].style.display = "none";
| |
| iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("p")[1].style.display = "none";
| |
| content.body.getElementsByTagName("footer")[0].style.display = "none";
| |
| // Add parent to links | | // Add parent to links |
| var anchors = iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("a"); | | let iframeWin = document.getElementById("iframeWin"); |
| for (var i=0; i<anchors.length; i++){ | | let anchors = iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("a"); |
| | for (let i=0; i<anchors.length; i++){ |
| anchors[i].setAttribute('target', '_parent'); | | anchors[i].setAttribute('target', '_parent'); |
| } | | } |
| // Show | | // Show iframe |
| document.getElementById('iframeDiv').style.display="block"; | | document.getElementById('iframeDiv').style.display="block"; |
| }); | | }); |
|
| |
|
| window.onload = function() { | | window.onload = function() { |
| var iframeWin = document.getElementById("iframeWin"); | | // 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; |