かなりの素人なので説明不足などで分かりづらいところが多々あると思いますが、
何卒宜しくお願い致します。
同じhtmlに複数のiframeがあるのですが、
その全てのiframeをランダムにしたいのですが、
あまりの素人なので全く分かりません。
申し訳ありませんが、
多少いじってコピペするくらいまでのソースを教えて頂けますでしょうか?
宜しくお願い致します。
iframe一つだけのランダムは以下のソースでできました。
<head>
<script type="text/javascript">
<!--
function RndmSubFlame(){
rlURL= new Array();
rlURL[0]="01.html"
rlURL[1]="02.html"
rlURL[2]="03.html"
n=rlURL.length;
x=Math.floor(Math.random()*n);
sub_flame.location.href = rlURL[x];
}
//-->
</script>
</head>
<body TopMargin=0 LeftMargin=0 RightMargin=0 BottomMargin=0 STYLE="overflow:auto;height:100%;" onLoad="RndmOpen()">
<script><!--
document.write("<iframe src=\""+riURL[x]+"\"></iframe>");
//-->
</body>
以下のhtmlのようなページです。
できましたら、このソースに書き加え頂けますと
大変助かります。
宜しくお願い致します。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title></title>
</head>
<body>
<table border="1" width="84%" height="87">
<tr>
<td width="33%" height="81"><iframe src="a01.html" frameborder="0" width="100%" height="190" name="01" scrolling="no"></iframe></td>
<td width="33%" height="81"><iframe src="a01.html" frameborder="0" width="100%" height="190" name="02" scrolling="no"></iframe></td>
<td width="34%" height="81"><iframe src="a01.html" frameborder="0" width="100%" height="190" name="03" scrolling="no"></iframe></td>
</tr>
</table>
</body>
</html>
No.2ベストアンサー
- 回答日時:
No.1の者です。
↓のソースは一部誤りがありましたので訂正します。(インラインフレーム名の先頭に適当な数字以外が必要でした。)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title></title>
<script type="text/javascript">
<!--
function RndmSubFlame(){
rlURL= new Array();
rlURL[0]="01.html"
rlURL[1]="02.html"
rlURL[2]="03.html"
n=rlURL.length;
x1=Math.floor(Math.random()*n);
x2=Math.floor(Math.random()*n);
x3=Math.floor(Math.random()*n);
s01.location.href = rlURL[x1];
s02.location.href = rlURL[x2];
s03.location.href = rlURL[x3];
}
//-->
</script>
</head>
<body onload="RndmSubFlame()">
<table border="1" width="84%" height="87">
<tr>
<td width="33%" height="81"><iframe src="a01.html" frameborder="0" width="100%" height="190" name="s01" scrolling="no"></iframe></td>
<td width="33%" height="81"><iframe src="a01.html" frameborder="0" width="100%" height="190" name="s02" scrolling="no"></iframe></td>
<td width="34%" height="81"><iframe src="a01.html" frameborder="0" width="100%" height="190" name="s03" scrolling="no"></iframe></td>
</tr>
</table>
</body>
</html>
ですがこの方法だと最初に移動音がでますのでこちらのほうがひょっとしたらいいかも知れません。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<title></title>
<script type="text/javascript">
<!--
rlURL= new Array();
rlURL[0]="01.html";
rlURL[1]="02.html";
rlURL[2]="03.html";
tw=new Array(33,33,34);
function xRandomFrame(){
doc="<table border='1' width='84%' height='87'><tr>";
for(i=0;i<3;i++){
doc+="<td width='"+tw[i]+"' height='81'><iframe src='"+rlURL[Math.floor(Math.random()*rlURL.length)]+"' frameborder='0' width='100%' height='190' name='0"+(i+1)+"' scrolling='no'></iframe></td>";
}
doc+="<tr></table>";
document.getElementById("field").innerHTML=doc;
}
//-->
</script> </head>
<body onload="xRandomFrame()">
<div id="field"></div>
</body>
</html>
No.1
- 回答日時:
3セット作ればいいのではないでしょうか?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title></title>
<script type="text/javascript">
<!--
function RndmSubFlame(){
rlURL= new Array();
rlURL[0]="01.html"
rlURL[1]="02.html"
rlURL[2]="03.html"
n=rlURL.length;
x1=Math.floor(Math.random()*n);
x2=Math.floor(Math.random()*n);
x3=Math.floor(Math.random()*n);
01.location.href = rlURL[x1];
02.location.href = rlURL[x2];
03.location.href = rlURL[x3];
}
//-->
</script>
</head>
<body onload="RndmSubFlame()">
<table border="1" width="84%" height="87">
<tr>
<td width="33%" height="81"><iframe src="a01.html" frameborder="0" width="100%" height="190" name="01" scrolling="no"></iframe></td>
<td width="33%" height="81"><iframe src="a01.html" frameborder="0" width="100%" height="190" name="02" scrolling="no"></iframe></td>
<td width="34%" height="81"><iframe src="a01.html" frameborder="0" width="100%" height="190" name="03" scrolling="no"></iframe></td>
</tr>
</table>
</body>
</html>
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- HTML・CSS 自身のHPにYouTube動画を貼り付けるのが出来なくなり困ってます 1 2022/11/11 10:44
- HTML・CSS (Javascript)印刷するファイルに応じて印刷プレビュー画面で用紙を自動的に切り替えたい!! 2 2022/04/11 12:04
- JavaScript jQueryでのドラッグアンドドロップについて 1 2022/07/30 09:10
- HTML・CSS cssが効かなくて困ってます 1 2023/01/01 23:57
- HTML・CSS 下にスクロールしても、追従するボタンのコードを書いたのですが、ボタンの中の画像が半分しか表示されない 1 2022/04/16 21:31
- HTML・CSS html/cssで要素が出てこなくて困ってます 1 2022/12/31 16:59
- HTML・CSS スクロールすると追従する画像のコードを書いているのですが、追従する画像の大きさの調節が上手くいきませ 2 2022/04/18 12:52
- JavaScript javascriptで変数を組み込みたい 2 2023/01/13 09:52
- AJAX JavascriptからPHPへのAjax通信でnullが返ってくる 3 2022/08/03 22:00
- JavaScript Javascript初心者|jQueryの.val()で値を取得し複数の要素を連結させる方法知りたい 2 2022/06/02 12:06
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
<JavaScript>tableタグを入力不...
-
指定のテキストをクリックする...
-
javascriptでクリックするごと...
-
JQueryでテーブルの行を追加し...
-
selectのonChangeが動作しません
-
javascriptで<table>背景色の取得
-
javascriptで画像をテーブルに...
-
tbody要素のinnerHTMLが書き換...
-
どこに挿入?
-
Tableの枠線(内・外)色を変更
-
セレクトボックスでそれ以降の...
-
【jQuery】tableループ内のIDの...
-
テキストエリアに入力した改行...
-
画面表示とともに、テーブルの...
-
return trueとreturn falseの用...
-
プルダウン 項目が多いので先頭...
-
localStorageでのcheckbox制御
-
onchangeイベントを強制的に発...
-
【jQuery】input nameの文字列...
-
テキストボックス入力を半角英...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
<JavaScript>tableタグを入力不...
-
画面表示とともに、テーブルの...
-
selectのonChangeが動作しません
-
テーブルの行数を可変長にした...
-
テキストエリアに入力した改行...
-
【jQuery】tableループ内のIDの...
-
idの振り直しについて
-
プルダウンメニューを表の中に...
-
javascriptで画像をテーブルに...
-
javascriptで<table>背景色の取得
-
javascriptでクリックするごと...
-
jquery にて、アラートダイアロ...
-
どこに挿入?
-
動的なcheckboxのcheckedについて
-
Javascriptでテーブルタグの座...
-
javascriptで画像の移動
-
クリックごとに文字色が交互に...
-
javascriptでスロットマシン
-
<iframe>内にHTMLをランダム表...
-
連動テーブルのクロスハイライト
おすすめ情報