サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
体力トレーニング
java.misty.ne.jp
マウスの動作を検出するためには 「onmouseover」と「onmouseout」のイベントハンドラを使用します。 イベントハンドラとは、マウスのクリックなどのアクションを JavaScript で検出するためのものです。 サンプル1では、イベントハンドラ「onmouseover」を使って、画像を変更する関数「rollOver」を呼び出しています。 [ 関数の呼び出し部分 (サンプルスクリプトの1番目) ] <img src="./img/rollover01a.gif" width="147" height="60" alt="" border="0" onmouseover="RollOver(this, './img/rollover01b.gif');" onmouseout="RollOver(this, './img/rollover01a.gif');"> 黄色の部分がイベ
「開始」ボタンを押すと徐々にページが表示されていきます。 実際にどのような感じになるか確認してみてください。 (* InernetExplore のみ有効な機能です) ページのフェードイン効果を出すためにスタイルシートの「filter」機能を使用しています。 filter 機能にはいろいろな機能がありますが、その中の「alpha オプション(透明度の指定)」を使用します。 alpha オプションでは0(不透明)~100(透明)までを数値で指定します。 始めにスタイルシートの設定でページ全体の透明度を0に指定しておきます。 これでページを読み込んだときには表示されない状態になっています。 次に、この透明度の指定を JavaScript を使って100まで段階的に変化させていきます。 すると徐々にページが表示されていきます。 これとは逆に、alpha オプションの値を100から0へと変化させて
HTML やスタイルシートはWebページをどのように表示するかを指示する言語ですが、 ユーザーの反応に合わせてページを変化させたりすることはできません。 JavaScript を使用するとマウス操作やキーボード操作に合わせてWeb ページを動的に変化させることができます。 JavaScript ではOS やブラウザー・ブラウザーのバージョンによって、同じスクリプトでも動作が違ったり、スクリプト内で使用している命令がそのブラウザーでは未対応であったりすることがあります。 そこで当サイトでは、解説ページの一番下に各ブラウザーの対応表を設けております。 これを参考にしてターゲットの環境に合ったスクリプトの作成を行なってみてください。 JavaSript 講座へようこそ! ホームページは作れるようになったがページにちょっとしたアクセントをつけたい! もっとインタラクティブなホームページにしたい!
<div class="sampleMenu01" onmouseover="popupMenu(this, 1,360,380);rollOver(this,'sampleMenu02');" onmouseout="displayMode('none');rollOver(this,'sampleMenu01');" >検索エンジン</div> サンプルのピンク色のメニューを表示しているソースです。 メニュー項目ごとに、このソースを追加していきます。 onmouseover の動作 「popupMenu」関数でサブメニュー(ポップアップメニュー)の表示を行います。 また、「rollOver」関数でメニューの色を薄いピンク色に変更しています。 色を変更することで、どのメニュー項目をポイントしているかがわかりやすくなります。 onmouseout の動作 「displayMode」関数でサ
このページを最初にブックマークしてみませんか?
『有限会社ミスティーネット JavaScript講座』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く