0

chrome browser

버전 : Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36

onclick link

<!DOCTYPE html>
<html>
<body>
<script>
function winopen(url){
    window.open(url, '_blank');
    }
</script>
<p>Open link in a new window or tab: <a href="javascript:winopen('https://www.w3schools.com');" target="_blank">Visit W3Schools!</a></p>

</body>
</html>

O : https://www.w3schools.com window open
X : about:blank window open

Cha
  • 3
  • 3
  • 1
    Don't use the `javascript` scheme. Use `onclick="winopen(url)"` or `addEventListener` to attach the event in JavaScript. You should also consider not using popups and the like. Let the users open URLs in the window they would like to open URLs in. It's much more user friendly. – Heretic Monkey Sep 04 '19 at 01:42
  • 1
    Read https://stackoverflow.com/questions/2479557/why-is-it-bad-practice-to-use-links-with-the-javascript-protocol for why you don't want to do this in the first place – Jaromanda X Sep 04 '19 at 01:43
  • Thanks for explaining the difference then suggesting a better way. – Cha Sep 04 '19 at 02:19

1 Answers1

0

I guess you are trying to open a link in a blank window? if you try changing your href so it points directly to the link.

HTML

    <!DOCTYPE html>
<html>

<body>
    <script>
        function winopen(url) {
            window.open(url, '_blank');
        }
    </script>
    <p>Open link in a new window or tab: <a href="https://www.w3schools.com" target="_blank">Visit W3Schools!</a></p>

</body>

</html>
Het
  • 54
  • 4
  • Please understand that it is not smooth because it is an answer using a translator. Session information should be transferred to other systems of other servers. The current system does not support SSO(Single Sign On). So it's implemented to use a script to move. The above source content is a simple example. It was a good script before. – Cha Sep 04 '19 at 02:14