電子書籍の厳選無料作品が豊富!

サブミットでもコマンドボタンでもどちらでもいいのですが
ボタンをクリックしたら、URLを開く方法はありますか?

サブミットボタンを押したら、
<a href="http://www.yahoo.co.jp/" target="_blank">新たなウインドウで開く</a>
この動きを実行したいです。

A 回答 (3件)

<button type="button" onclick="window.open('

http://www.yahoo.co.jp/','_blank');">新たなウインドウで開く</button>
    • good
    • 0
この回答へのお礼

回答ありがとうございました。

お礼日時:2014/09/02 22:42

FORMタグに


target="_blank"
を入れて試してみましたか?
    • good
    • 0
この回答へのお礼

回答ありがとうございました。

お礼日時:2014/09/02 22:42

リンクなのですから、HTMLはリンクのままで良いですよ。


プレゼンテーションはスタイルシートで指定するのが原則ですから
<a href="http://www.yahoo.co.jp/" onclick="window.open('http://www.yahoo.co.jp/'); return false;">Yahoo!</a>
単純に・・
a[href="http://www.yahoo.co.jp/"]{
display:inline-block;
padding:0.5em 2em;
border:outset 5px silver;
text-decoration:none;
color:black;background-color:silver;
}
a[href="http://www.yahoo.co.jp/"]:hover,
a[href="http://www.yahoo.co.jp/"]:focus{
color:gray;
background-color:white;
border-color:gray;
}
a[href="http://www.yahoo.co.jp/"]:active{
border-style:inset;
color:white;
background-color:gray;
}

とか
 画像にすることも、その段落の右や左に置くこともスタイルシートで自由自在にできます。media="screen"に適用ユーザーエージェントを指定しておくと、印刷や携帯電話にはこのデザインは適用されませんし、検索エンジンにもリンクだと認識してもらえます。
 構造とプレゼンテーションの分離( http://www.asahi-net.or.jp/%7Esd5a-ucd/rec-html4 … )

[実例]
★Another HTML Lint - Gateway( http://www.htmllint.net/html-lint/htmllint.html# )
 のDATAで検証済みのHTML4.01strict + CSS2.1です。
★javascriptが無効のブラウザでもリンクします。
★印刷や携帯電話、点字端末、スクリーンリーダー、そして検索エンジンにもOK
★ウィンドウ幅に依存しません。
★タブは_に置換してあるので戻す。


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
_<meta http-equiv="content-type" content="text/html; charset=Shift_JIS">
_<meta http-equiv="content-script-type" content="text/javascript">
_<title>サンプル</title>
_<meta name="author" content="ORUKA1951">
_<meta http-equiv="Content-Style-Type" content="text/css">
_<link rev="made" href="mailto:oruka1951@hoge.com" title="send a mail" >
_<link rel="START" href="../index.html">
_<style type="text/css" media="screen">
<!--
html,body{margin:0;padding:0;}
h1,h2,h3,h4,h5,h6{margin:0;line-height:1.6em;}
p{text-indent:1em;}
div.header,div.section,div.footer{width:90%;min-width:630px;max-width:900px;margin:0 auto;padding:5px;}
a[href="http://www.yahoo.co.jp/"]{
display:inline-block;
padding:0.5em 2em;
border:outset 5px silver;
text-decoration:none;
color:black;background-color:silver;
}
a[href="http://www.yahoo.co.jp/"]:hover,
a[href="http://www.yahoo.co.jp/"]:focus{
color:gray;
background-color:white;
border-color:gray;
}
a[href="http://www.yahoo.co.jp/"]:active{
border-style:inset;
color:white;
background-color:gray;
}
-->
_</style>
</head>
<body>
_<div class="header">
__<h1>タイトル</h1>
__<p>このページでは<a href="http://www.yahoo.co.jp/" onclick="window.open('http://www.yahoo.co.jp/'); return false;" onkeypress="window.open('http://www.yahoo.co.jp/')">Yahoo!</a></p>
_</div>
_<div class="section">
__<h2>見出し</h2>
__<p>本文はsection</p>
__<div class="section">
___<h3>項見出し</h3>
___<p>本文項記事</p>
___<p>sectionの階層でレベルが判断される</p>
__</div>
_</div>
_<div class="footer">
__<h2>文書情報</h2>
__<dl class="documentHistry">
___<dt id="FIRST-PUBLISHED">First Published</dt>
___<dd>2013-03-03</dd>
__</dl>
_</div>
</body>
</html>
    • good
    • 0
この回答へのお礼

回答ありがとうございました。

お礼日時:2014/09/02 22:42

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!