ASDSO Dam Safety Toolbox

Template: WhatLinksHere: Difference between revisions

From ASDSO Dam Safety Toolbox
Jump to: navigation, search
No edit summary
No edit summary
 
(77 intermediate revisions by the same user not shown)
Line 1: Line 1:
<noinclude>
<html>
== Usage ==
  <div id="iframeDiv" style="display:none;">
{{WhatLinksHere|source=/wiki/Special:WhatLinksHere/Main_Page}}
    <hr style="width:5%;">
</noinclude>
    <h4>What links here</h4>
    <iframe id="iframeWin"
            src="/wiki/Special:WhatLinksHere/</html>{{PAGENAME}}<html>"
            style="border:none;width:100%;"></iframe>
  </div>


  <script>
    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++){
        anchors[i].setAttribute('target', '_parent');
      }
      // Show iframe
      document.getElementById('iframeDiv').style.display="block";
    });


----
    window.onload = function() {
<html>
      // Set styles
<iframe id="iframeWin"
      let iframeStyles = `
         src="{{{source}}}"
         <style>
        style="border:none;height:500px;width:100%;display:none;"
          #maincontentwrapper {
         scrolling="no"  
            margin-left: 0px;
        title="What Links Here"></iframe>
            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;


<script>
      // Set height
document.querySelector("iframe").addEventListener( "load", function(e) {
      iframeWin.height = iframeWin.contentWindow.document.body.scrollHeight;
  var iframeWin = document.getElementById("iframeWin");
    }
  var content = (iframeWin.contentWindow || iframeWin.contentDocument);
  </script>
  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 & 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";
  content.body.getElementsByTagName("footer")[0].style.display = "none";
  // Show iframe
  iframeWin.style.display="block";
});
</script>
</html>
</html>

Latest revision as of 15:11, 9 August 2023