Template:PopupLink: Difference between revisions

From lotico
Jump to navigation Jump to search
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 1: Line 1:
<includeonly>
<includeonly>
<a href="{{{1|#}}}"
[{{{1|#}}} {{{2|Click here}}}]
  title="{{{3|}}}"  
<script>
  target="{{{4|_self}}}">{{{2|Click here}}}</a>
document.addEventListener('DOMContentLoaded', function() {
  var links = document.querySelectorAll('a[href="{{{1|#}}}"]');
  links.forEach(function(link){
    link.onclick = function(e){
      e.preventDefault();
      window.open(link.href, '{{{4|_self}}}');
    };
  });
});
</script>
</includeonly>
</includeonly>
<noinclude>
<noinclude>
Usage: {{PopupLink|URL|Link Text|Popup Text|Target}}
Usage: {{PopupLink|URL|Link Text|Popup Text|Target}}
- URL: the link (default: #) 
Target can be _blank, _top, etc.
- Link Text: text shown (default: Click here) 
- Popup Text: text on hover (optional) 
- Target: _self, _blank, _top, _parent (default: _self)
 
Example:
{{PopupLink|https://example.com|Example|This is a popup|_blank}}
</noinclude>
</noinclude>

Revision as of 22:03, 6 September 2025


Usage: [URL Link Text] <script> document.addEventListener('DOMContentLoaded', function() {

 var links = document.querySelectorAll('a[href="URL"]');
 links.forEach(function(link){
   link.onclick = function(e){
     e.preventDefault();
     window.open(link.href, 'Target');
   };
 });

}); </script>


Target can be _blank, _top, etc.