インラインフレーム内に文字を表示する


■動作ブラウザ 【 IE:3.0  NN:6.0】
Internet Explorer Netscape Navigator DreamPassport iCab
3.0x 4.0x 4.5 5.0x 5.5 2.0x 3.0x 4.0x 4.x 6.0 2 3 2.x
Windows ○ ○ - ○ ○ × × × × ○ - × -
Macintosh ○ ○ ○ ○ - × × × × ○ - - ×
UNIX - - - - - × × × × ○ - - -
Dreamcast - - - - - - - - - - × × -

ポイント txt = document.myFORM.myTEXT.value; myFrame.document.open(); myFrame.document.write(txt); myFrame.document.close();
説  明 インラインフレーム内に文字を表示するには「インラインフレーム名.document.write(表示文字)」のようにします。すでに表示されている内容を消してから表示する場合は表示前に「インラインフレーム名.document.open()」、表示後は「インラインフレーム名.document.close()」とします。
サンプル <html> <head> <title>インラインフレーム内に文字を表示する</title> <script language="JavaScript"><!-- function setText() { txt = document.myFORM.myTEXT.value; myFrame.document.open(); myFrame.document.write(txt); myFrame.document.close(); } // --></script> </head> <body> <form name="myFORM"> <input type="text" name="myTEXT"> <input type="button" value="書き込む" onClick="setText()"> </form> <iframe src="dummy.html" name="myFrame" width="320" height="240"></iframe> </body> </html>
補足説明 なし

■サンプルスクリプトを実行する >>実行
■各ブラウザでの動作結果を見る >>View!

写真素材 PIXTA