かなりの素人なので説明不足などで分かりづらいところが多々あると思いますが、
何卒宜しくお願い致します。
同じ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で質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・街中で見かけて「グッときた人」の思い出
- ・「一気に最後まで読んだ」本、教えて下さい!
- ・幼稚園時代「何組」でしたか?
- ・激凹みから立ち直る方法
- ・1つだけ過去を変えられるとしたら?
- ・【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
- ・【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
- ・映画のエンドロール観る派?観ない派?
- ・海外旅行から帰ってきたら、まず何を食べる?
- ・誕生日にもらった意外なもの
- ・天使と悪魔選手権
- ・ちょっと先の未来クイズ第2問
- ・【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
- ・推しミネラルウォーターはありますか?
- ・都道府県穴埋めゲーム
- ・この人頭いいなと思ったエピソード
- ・準・究極の選択
- ・ゆるやかでぃべーと タイムマシンを破壊すべきか。
- ・歩いた自慢大会
- ・許せない心理テスト
- ・字面がカッコいい英単語
- ・これ何て呼びますか Part2
- ・人生で一番思い出に残ってる靴
- ・ゆるやかでぃべーと すべての高校生はアルバイトをするべきだ。
- ・初めて自分の家と他人の家が違う、と意識した時
- ・単二電池
- ・チョコミントアイス
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
<JavaScript>tableタグを入力不...
-
連動テーブルのクロスハイライト
-
onchangeイベントを強制的に発...
-
プルダウン 項目が多いので先頭...
-
JavaScriptにて動的に配列を作...
-
特定<table>内の<td>の色を変える
-
クリックさせたいが、click()が...
-
return trueとreturn falseの用...
-
フォームの入力チェックをする...
-
slickのレスポンシブ > center...
-
チェックに応じて違うチェック...
-
ハイパーリンクを別ウインドウ...
-
name属性のないformタグの、中...
-
ホームページビルダーのスクリ...
-
現在フォーカスのオブジェクト...
-
VBScriptでHTMLのセレクトボッ...
-
%の計算の仕方
-
ラジオボタンにタブインデック...
-
submitするとなぜか2度実行する
-
2次元配列で2項目についてソー...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
<JavaScript>tableタグを入力不...
-
テーブルの行数を可変長にした...
-
selectのonChangeが動作しません
-
画面表示とともに、テーブルの...
-
javascriptで<table>背景色の取得
-
javascriptでクリックするごと...
-
テキストエリアに入力した改行...
-
【jQuery】tableループ内のIDの...
-
<iframe>内にHTMLをランダム表...
-
javascriptで画像をテーブルに...
-
WEB制作に関する質問です。コン...
-
javascript でテーブル操作
-
カレンダーに印を付けたい
-
日にち指定によるテーブル/行の...
-
テーブルのtdの中に、重複避け...
-
innerHTMLでのテーブル作成
-
プルダウンメニューを表の中に...
-
簡単なJavaスロットマシーンに...
-
javascriptで表に画像を貼る
-
javascriptで画像の移動
おすすめ情報