• ベストアンサー

フレームサイズの変更について

過去ログを参照していたら、次のようなサンプルを発見したのですが、 IEでは動作しますが、FireFoxではエラーになってしまいます。 どこを修正すれば動くようになるでしょうか? ■frame.html■ <html> <head><title></title> <script language="javascript"> <!-- document.write(frset('40%','60%','a.htm?','1.htm?')) function frset(a,b,f1,f2){ var frset= '<title>frame</title>\n' +'<frameset cols="'+a+','+b+'">\n' +'<frame src="'+f1+'">\n' +'<frame src="'+f2+'">\n' +'</frameset>\n' return frset } //--> </script> </head> </html> ■a.html■ <html> <head><title></title> </head> <body> 右のリンクで<br>フレームのサイズ<br>が変わるよ! </body> </html> ■1.html■ <html> <head><title></title> <script language="javascript"> <!-- function chsize(a,b){ if(location.search==""){ if(document.all){ parent.document.all.tags("frameset")[0].cols=a+","+b }else{ //parent.document.open() parent.document.write(frset(a,b,parent.frames[0].location.href+"?",parent.frames[1].location.href+"?")) parent.document.close() } } } //--> </script> </head> <body onload="chsize('40%','60%')"> こっち側60%です。 <br> <a href="2.htm">こっち側を40%にする!</a> </body> </html> ■2.html■ <html> <head><title></title> <script language="javascript"> <!-- function chsize(a,b){ if(location.search==""){ if(document.all){ parent.document.all.tags("frameset")[0].cols=a+","+b }else{ //parent.document.open() parent.document.write(frset(a,b,parent.frames[0].location.href+"?",parent.frames[1].location.href+"?")) parent.document.close() } } } //--> </script> </head> <body onload="chsize('60%','40%')"> <a href="1.htm">こっち側を60%にする!</a> <br> こっち側40%です。 </body> </html>

質問者が選んだベストアンサー

  • ベストアンサー
  • leap_day
  • ベストアンサー率60% (338/561)
回答No.2

こんにちは frame.htmlもjavascriptで書いてるけど特別な意味が? サイズチェンジならこれでできると思います "40%,60%"を変更 <script language="javascript"><!-- function sizech() { parent.document.getElementsByTagName("frameset")[0].cols = "40%,60%"; } //--></script> <a href="***.html" onClick="sizech()">framesize change</a>

全文を見る
すると、全ての回答が全文表示されます。

その他の回答 (3)

  • yambejp
  • ベストアンサー率51% (3827/7415)
回答No.4

細かいはなしですがframesetは、片方がきまったら もう片方は*にするのが妥当です。 "60%,*"とか"40%,*"とか・・・

w0a15455
質問者

お礼

問題解決です。 助かりました。 みなさんありがとうございました。

全文を見る
すると、全ての回答が全文表示されます。
  • leap_day
  • ベストアンサー率60% (338/561)
回答No.3

#2です すみません。ちょっと修正(><) body onloadだから表示したときに変更ですね・・・ 【frame.html】 <frameset cols="40%,60%"> <frame src="a.html"> <frame src="1.html"> </frameset> 【1.html】 <script language="javascript"><!-- window.onload=function() { parent.document.getElementsByTagName("frameset")[0].cols = "40%,60%"; } //--></script> 【2.html】 <script language="javascript"><!-- window.onload=function() { parent.document.getElementsByTagName("frameset")[0].cols = "60%,40%"; } //--></script>

全文を見る
すると、全ての回答が全文表示されます。
noname#39970
noname#39970
回答No.1

>parent.document.all.tags("frameset")[0] http://www.tohoho-web.com/js/dom.htm#getElementsByTagName document.all という用法は「IE専用」

全文を見る
すると、全ての回答が全文表示されます。

関連するQ&A

  • フレーム内リンクを禁止したい

    表題のとおり、フレーム内へのリンクを禁止したく <script language="JavaScript"> <!-- if (parent.location.href != window.location.href) parent.location.href= window.location.href; //--> </script> を<head>と</head>の間に入れてみましたが、「書き込みができません。」とエラーになります。 どこか間違っているのでしょうか。

  • JavaScript フレーム

    Javascriptをふたつ書くことはできないんですか? 2つ書いたら「い」のほうしか宣言されないんでどうしたらよろしいですか? Update.java,kensaku2.java syouhin_kensaku.html,syouhin_master.html <html> <head> <title>メニュー</title> </head> <body> <script type="text/javascript"> <!-- function jump(){ // 設定開始(表示するフレーム名とリンク先URLを設定してください) parent.hakusi.location.href = "syouhin_kensaku.html"; parent.hakusi2.location.href = "Update"; // 設定終了 } // --> </script> <a href="#" onClick="jump(); return false;">あ</a> <br> <br> <script> <!-- function jump(){ parent.hakusi.location.href = "syouhin_master.html"; parent.hakusi2.location.href = "kensaku2"; //設定終了 } // --> </script> <br> <a href="#" onClick="jump(); return false;">い</a> <br> <br> </body> </html>

  • location.hrefを使用したFRAME表示

    location.hrefを使ったjavascriptを作ろうとしています。 <script type="text/javascript"><!-- location.href = "http://www.yahoo.co.jp/"; // --></script> の改良版として、http://www.yahoo.co.jp/をフレームの右側に 表示させたいと考えています。 (src使用ではなくjavascriptのlocation.hrefを使うことがMUSTです) <head> <script type="text/javascript"><!-- right.location.href = "http://www.yahoo.co.jp/"; // --></script> </head> <body> <FRAMESET cols="50%,50%"> <FRAME name="left" src="left.html"> <FRAME name="right" src="right.html"> </FRAMESET> </body> としてみましたがうまくいきません。 location.hrefはmetaタグ内でしか有効ではないにも関わらず right.の指示をメタタグ内部で指定していないことが原因かも しれません。 javascriptのlocation.hrefを使ってフレームの右側に 表示させる方法をご教授願います。

  • 入れ子のフレームでjavascriptが上手く動作しない

    frame.html ----- フレームセットを設定している frm1.html ------ フレーム1に表示する frm2_a.html ---- フレーム2に最初に表示する frm3_a.html ---- フレーム3に最初に表示する frm2_b.html ---- フレーム2に二番目に表示する frm3_b.html ---- フレーム3に二番目に表示する jscript.js ----- 外部javascript frame.html(抜粋) <head> <script type="text/javascript" src="jscript.js"></script> </head> <frameset cols="*, 200px"> <frameset rows="*, 100px"> <frame src="frm1.html" name="フレーム1" onload="addHtml()" noresize> <frame src="frm2_a.html" name="フレーム2" noresize> </frameset> <frame src="frm3_a.html" name="フレーム3" noresize> <noframes> </noframes> </frameset> jscript.js(抜粋) function addHtml(){ alert("in"); parent.フレーム2.location.href = "frm2_b.html"; parent.フレーム3.location.href = "frm3_b.html"; parent.フレーム3.document.getElementById("addArea").innerHTML = "追加内容"; alert("out"); return; } frm3_b.html(抜粋) <body> <div id="addArea"><div> </body> frm.htmlをブラウザ(IE系)で表示 → onloadイベントでaddHtml()  → フレーム切り替え、"追加内容"をaddAreaに追加  → 追加されず、alert("out")の行が実行されない。 更新ボタンを押し、alert("in")をOKボタンで消し、 次のalert("out")のダイアログを表示している間だけ追加された内容が表示され、 OKボタンで消すとaddArea内の内容が消えます。 フレーム1にページが読み込まれたときにイベントでスクリプトを 動かしたいのですが、うまくいかずこまっています。 問題点や改善点、別のやり方等教えていただけないでしょうか。 不明な点がございましたら、訂正・補足いたします。 よろしくおねがいします。

  • マウスオーバーでフレームに対応した内容を表示・・・。

    こんにちは。 いつもお世話になっております。 参考にしたサイト http://www.openspc2.org/reibun/javascript/frame/003/index.html 【内容】 フレーム分割のページ等の内容は以下の通りです。 ●フレーム分割ページ <html> <head> <title>マウスオーバーで右側フレームに対応した内容を表示する</title> <frameset cols="20%,*"> <frame src="code_left.html"> <frame src="code_right.html" name="rightFrame"> </frameset> </head> </html> ●左側のページ(code_left.html) <html> <head> <title>マウスオーバーで右側フレームに対応した内容を表示する</title> <script language="JavaScript"><!-- function setFrame(jpURL) { parent.rightFrame.location.href = jpURL; } // --></script> </head> <body> <a href="#" onMouseover="setFrame('page1.html')">その1</a><br> <a href="#" onMouseover="setFrame('page2.html')">その2</a><br> </body> </html> で、意図した動きが出来たのですが、その1をクリックするとcode_left.htmlが別窓で開いてしまいます。 参考にしたサイトのサンプル画面ではこのような 動きにはならないのに、なぜ別窓が開いてしまうのか がわからないのです。 どうかご指導よろしくお願いいたします。

  • Mac-IEでの複数フレームのリンク

    02-01-18のkyappunさんの質問と内容的には同じなのですが。 フレーム使用のホームページで、複数フレームを同時に変更したいのですが、MacのIE(5.0)では、どうしても動作しません。 ※WinのIE6.0、NN4.7、NN6.0、MacのNN4.7では動作します。…が、MacのIEでも 動いてほしいのです。 ソースは、以下のようにしました。 (このソースには、こだわってないです) 解決法をご存知の方がいらっしゃいましたら、どうかよろしくお願いします。 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <title>フレームのリンク</title> <SCRIPT Language="JavaScript"> <!-- function changepage(top,bottom) {     parent.head.location.href=top;   parent.main.location.href=bottom; } //--> </SCRIPT> </head> <body> <form> <a href="javascript:changepage('head2.html','main2.html')">リンク1</a> <br> <a href="javascript:changepage('head3.html','main3.html')">リンク2</a> </form> </body> </html>

    • ベストアンサー
    • Mac
  • 他のフレームにあるボタンを使用不可にするには?

    2つのフレームに分割した画面で、一方のフレームにあるボタンを押したら、他のフレームにあるボタンを使用できなくしたいのですが、うまくいきません。下記のスクリプトでは、エラーになってしまいます。どのようにしたら良いでしょうか、よろしくお願いいたします。 <フレームの設定> <html> <head><title>フレームを縦に分割する</title></head> <frameset cols="50%,50%"> <frame src="left.html" name="light_frame" frameborder=1 border=1> <frame src="right.html" name="left_frame" frameborder=1 border=1> </frameset> </html> <left.htmlの内容> <html> <head> </head> <body> <form name="myform"> <input type="button" name="bt_del" value="削除"> </form> </body> </html> <right.htmlの内容> <SCRIPT Language="JavaScript"> function func1(){ //NG parent.left_frame.document.form.myform.bt_del.disabled = true; //これもNGでした //parent.left_frame.document.forms['myform'].bt_del.disabled = true; } </SCRIPT> <html> <head> </head> <body> <p><input type="button" value="変更" onclick="func1()" > </body> </html> 以上です。

  • 親ウィンドウの別フレームを子ウィンドウから操作したい

    いろいろ試しているのですが、理解不足のせいでしょうが、どうやってもできません! 内容は以下の通り(分からないのは3)です。どうぞ宜しくお願いいたします。 1:画面を、AとBの2つのフレームに分割しています。 【index.html】 <frameset>  <frame src="A.html" name="A">  <frame src="B.html" name="B"> </frameset> 2:Aフレーム内に記述してあるaaaアンカーをクリックすると、子画面ko.htmlを開きます。 <a href="javascript:void(0)" onclick="window.open('path=ko.html','_blank');">子画面</a> 3:ko.htmlではbbbというアンカーがあって、それをクリックすると、"親画面のBフレームにbbbで指定したリンク内容を表示したい"のです。 <a href="javascript:void(0)" onclick="opener.window.location=('B?path=/home/~/~/ZZZ.html');">開きたいファイルZZZ.html</a> と書くと、openerはAだからAにZZZ.htmlの内容が表示されてしまうので、(全くおかしな記述をしているのかもしれませんが・・・(- -;))あちこち調べながら、 B.opener.window.locationとか、 B.opener.window.location.hrefとか、 parent.B.window.locationとか、 parent.frames[1].window.locationとか、 ほかにもいろいろやってみたのですが、出来ませんでした・・・。 このような別フレームの操作が出来る方法があれば教えてください。 宜しくお願いいたします。

  • フレームで呼び出したhtml名の取得

    お世話になります。 http://oshiete1.goo.ne.jp/kotaeru.php3?q=2374524 で、教えて頂いた関数呼び出しについてです。 フレームを左右に分割しています。 左側 frame_left.html    name="left" 右側 最初page1.html    後でページを切り替える name="main" としたとき、 frame_left.htmlで <a href="page2.html" onclick='getTagName();' target="main">ページ2</a> とすると、右側フレームはpage2.htmlに切り替わります。 このとき、getTagName();が、ページが切り替わった後に実行される方法として、 No1.talepandaさんに、 <body onload="window.parent.left.getTagName();"> と、いう方法を教えて頂きました。 ここで、関数getTagName()で、この呼び出したhtml名、つまりpage2.htmlを取得できないものでしょうか。 いろいろと試してみました。 alert("window.parent.mainfrm.location.href="+window.parent.mainfrm.location.href); //framesetを定義したhtml名となってしまう。 alert("window.mainfrm.location.href="+window.mainfrm.location.href); //スクリプト停止 alert("location.href="+location.href); //frame_left.htmlになる。 と、いうことでいずれもダメでした。 このような呼び出し方をした場合、呼び出しもとのhtml名を取得できないのでしょうか。 どうか、よろしくお願いいたします。

  • Aフレームからの操作でBフレームに表示

    今日は。 現在HPを作ってるんですが、行き詰ってしまい、質問させて頂きます。 例として、 a.htmlとb.htmlの2つのフレームがあり a.htmlの小さな画像にオンマウスすると、b.htmlのフレームに大きな画像が表示される(別フレームに画像が表示されるのはオンマウス中のみです;) というのがしたくて調べたんですが <a onMouseOver="window.parent.フレームの名前.location.href = '大きな画像';"> <img src="小さい画像" border=0> </a> と書けば良いと言うのを発見し、試してみたんですが、小さい画像は表示されるんですが、オンマウスしても大きな画像がb.html に表示してくれません; 私が書いたのは、bodyの中に <a onMouseOver="window.parent.b.html.location.href = '0.mpg';"> <img src="1.mpg" border=0> </a> です。a.htmlの方に書きました。 上のやつを、b.htmlじゃなくbだけにしても駄目でした。 後、 Window.top.frames['main'].document.getElementById('registerForm').submit(); ってのも見つけたのでためしてみたんですが、ダメでした。 他にも、http://oshiete1.goo.ne.jp/qa1555396.htmlのを試してみたんですが、出来ませんでした。 これは、私がやりたいのと少し違ったので、テキストは表示されないように消したりしました; どなたか解決策を教えて頂けないでしょうか。 どうぞよろしくお願い致します。

    • ベストアンサー
    • HTML
このQ&Aのポイント
  • dcpj-526nの購入を検討中ですが、家にスマホ以外のネット環境がないため、スマホの写真やネット記事を無線でプリントアウトすることができるか知りたいです。
  • お使いの環境はAndroidで、接続方法はなしです。関連するソフト・アプリは特にありません。電話回線の種類については記載がありません。
  • この質問はブラザー製品に関するものです。
回答を見る

専門家に質問してみよう