仅通过页面加载中的click事件在新选项卡上导航链接

Looking for any JS/jQuery or CSS which accomplishes on clicking any part within the <body> tag must navigate to website in new tab referenced in the <script> tag that which is embedded within the <span>. Here the script will be called on Load of a Page for the first time

<body>
   ...
   ...
    <span>
        <script src="https://stackoverflow.com/" type="text/javascript"></script>
    </span>
</body>

Here is the below partial snippet, showing the result of appending the <span> from DOMContentLoaded above the closing </body> tag

document.addEventListener('DOMContentLoaded', function() {
  let createSpan = document.createElement('span');
  let createScript = document.createElement('script');
  createScript.src = 'https://stackoverflow.com/';
  createScript.type = 'text/javascript';
  createSpan.appendChild(createScript);
  document.body.appendChild(createSpan);
}, false);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<body>
      <!-- Any where clicked within the body area should navigate to the website referencing in the script over a new tab--> 
</body>

The same script should be modified in such a way that, on loading a website for the very first time, and clicking anywhere with in the browser window i.e., with <body> must navigate to a website in a new tab

Any modification to the HTML by CSS effect should only be passed/scripted from the JS/jQuery.

评论