LoginSignup
4
7

More than 5 years have passed since last update.

[ JavaScript ] リンクを開く

Last updated at Posted at 2016-09-12
open_url.html
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <title>Javascript でリンクを開く</title>
    <script>
        // 同一画面でリンクを開く
        function openURL(url) { location.href = url; }

        // 別画面でリンクを開く
        function openWIN(url) { window.open(url); }
    </script>
</head>

<body>
    <a href="javascript:void('0');" onclick="openURL('https://www.google.co.jp/')">同一画面でリンクを開く</a><br>
    <a href="javascript:void('0');" onclick="openWIN('https://www.google.co.jp/')">別画面でリンクを開く</a>
</body>
</html>
4
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
7