![](http://oshiete.xgoo.jp/images/v2/pc/qa/question_title.png?e8efa67)
サブミットでもコマンドボタンでもどちらでもいいのですが
ボタンをクリックしたら、URLを開く方法はありますか?
サブミットボタンを押したら、
<a href="http://www.yahoo.co.jp/" target="_blank">新たなウインドウで開く</a>
この動きを実行したいです。
No.1ベストアンサー
- 回答日時:
<button type="button" onclick="window.open('
http://www.yahoo.co.jp/','_blank');">新たなウインドウで開く</button>No.3
- 回答日時:
FORMタグに
target="_blank"
を入れて試してみましたか?
No.2
- 回答日時:
リンクなのですから、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>
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
HTML属性での「""」 「''」違い
-
htmlのolやulなどlistにtitleや...
-
<!-- #BeginLibraryItemとは
-
hタグの右横に画像を表示
-
html の divとtable の役割
-
htmlの見出しタグ(<h1>)の次...
-
min-heightとheightの違いについて
-
1時間30分を簡単に表したいで...
-
<div id="container">の使いか...
-
divの中に外部のHTMLを埋め込む
-
セクションをdivで囲むと見出し...
-
html5でheaderの中にnav
-
ヘッダーを左右に二分割する方...
-
画面を縮小するとカラムが落ち...
-
インラインフレームのページ内...
-
background-imageが効かない
-
横並びdivで一部の初期高さがず...
-
divとpの使いわけ
-
HTMLのJIS規格について
-
h1を親要素の縦中央、画像の横...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
htmlのolやulなどlistにtitleや...
-
HTML属性での「""」 「''」違い
-
html の divとtable の役割
-
<div id="container">の使いか...
-
複数のボタンを等間隔に、かつ...
-
min-heightとheightの違いについて
-
div要素が重なってします
-
1時間30分を簡単に表したいで...
-
スペースを使わず文字位置を揃...
-
<div>テキスト</div>
-
ヘッダーとフッターだけ背景を...
-
divを横に並べる方法
-
hタグの右横に画像を表示
-
セクションをdivで囲むと見出し...
-
divの中に外部のHTMLを埋め込む
-
h1のテキストサイズよりh2の方...
-
html5でheaderの中にnav
-
<!-- #BeginLibraryItemとは
-
3カラムレイアウトで「常に残り...
-
divとpの使いわけ
おすすめ情報