クロスブラウザする方法。

[上に] [前に] [次に]
saki [E-Mail] 2000/03/21(火) 04:28:29
以下のようなスクリプトを、
NNでもIEと同様な結果を得られるようにするにはどうしたらよいでしょうか。
ずーっと考えてたんですが、うまくいきませんでしたので、
ご教授下さい。

<SCRIPT LANGUAGE="javascript">
<!--
function view(name) {
  if(document.layers){ var txtObj = document.layers[name];
  if (txtObj.display != 'none') { txtObj.display = 'none'; }
  else { txtObj.style.display = ''; }
}
  else if (document.all){var txtObj = document.all(name);
  if (txtObj.style.display != 'none') { txtObj.style.display = 'none'; }
  else { txtObj.style.display = ''; }
}
}
// -->
</SCRIPT>
<a href="javascript:view('a')">クリック</a>
<br>
<table ID="a" STYLE="display:none;" width=100% height=150><tr><td bgcolor=blue>
</td></tr></table>
<table width=100% height=150><tr><td bgcolor=red>
</td></tr></table>

Aurai 2000/03/21(火) 05:02:50
<SCRIPT LANGUAGE="javascript">
<!--
function view(name) {
  if(document.layers) with(document.layers[name]){
    if (visibility != 'hide') { visibility = 'hide'; }
    else { visibility = 'show'; }
  }
  else with(document.all(name)){
    if (style.visibility != 'hidden') { style.visibility = 'hidden'; }
    else { style.visibility = 'visible'; }
  }
}
// -->
</SCRIPT>
<a href="javascript:view('a')">クリック</a>
<br>
<SPAN ID=a STYLE="visibility:hidden">
<LAYER NAME=a VISIBILITY="hide">
<table width=100% height=150><tr><td bgcolor=blue><br>
</td></tr></table>
</LAYER>
</SPAN>
<table width=100% height=150><tr><td bgcolor=red><br>
</td></tr></table>

http://www.tohoho-web.com/wwwxx023.htm
を参考にしてみました
DHTMLは全然わかっていないので変なところあるとおもいます

saki 2000/03/21(火) 10:58:47
素早い回答、大変ありがとうございます。
しかしながら、これではちょっと、思っていたのと違ってきてしまいました。
青のテーブルが出現することによって、
赤のテーブルが、下側にスライドするようなものにしたかったのです。
初めに明確にそういう意思表示をするべきでした。
申し訳ありません。
引き続き、回答をお待ちしております。

nobut [E-Mail] [HomePage] 2000/03/22(水) 02:48:48
<SCRIPT LANGUAGE="javascript">
<!--
var cc = " ";
function fnc(c,l){
if(c==" "){
        if(document.layers){
                 document.layers[l].document.open();
                 document.layers[l].document.write(cc);
                 document.layers[l].document.close();
         }
         if(document.all){
                 document.all(l).innerHTML = cc;
         }
}
else cc = cc + c;
}
var check = false;
function view(l){
cc = " ";
if(check){
check = false;
fnc('<table width=100% height=150><tr><td bgcolor=blue><br></td></tr></table>',l);
}
else check = true;
fnc('<table width=100% height=150><tr><td bgcolor=red><br></td></tr></table>',l);
fnc(' ',l);
}
// -->
</SCRIPT>
</head>
<body onLoad="view('a');">
<a href="javascript:view('a')">クリック</a>
<div id="a" style="position:absolute;top:30;"></div>
完全に別物になってるけどこれじゃあだめかな。

saki 2000/03/22(水) 08:32:49
うーん。。申し訳ありません。せっかく書いてもらったのに。
元のスクリプトを簡略化しすぎました(私が)。
以下のスクリプトのように、
赤のテーブルの上に、
青と緑ののテーブルを両方出した状態で、
青のテーブルをクリックすると、緑が残ると言った感じにしたかったのです。
何度も何度も申し訳ありません。
でも、テーブルをスクリプトの中に組んでしまうのはちょっと魅力的だと思いました。
test.jsの形で別ファイルにしてしまえば、ソースを覗かれても、
そのテーブルの内容が見えないのはすっきりしていいかなと。

<SCRIPT LANGUAGE="javascript">
<!--
function view(name) {
  if(document.layers){ var txtObj = document.layers[name];
  if (txtObj.display != 'none') { txtObj.display = 'none'; }
  else { txtObj.style.display = ''; }
}
  else if (document.all){var txtObj = document.all(name);
  if (txtObj.style.display != 'none') { txtObj.style.display = 'none'; }
  else { txtObj.style.display = ''; }
}
}
// -->
</SCRIPT>
<a href="javascript:view('a')">青のテーブル</a>  <a href="javascript:view('b')">緑のテーブル</a>
<br>
<table ID="a" STYLE="display:none;" width=100% height=150><tr><td bgcolor=blue>
</td></tr></table>
<table ID="b" STYLE="display:none;" width=100% height=150><tr><td bgcolor=green>
</td></tr></table>
<table width=100% height=150><tr><td bgcolor=red>
</td></tr></table>

saki 2000/03/22(水) 08:38:34
あ、それからview('a')、view('B')………
と、無限にテーブルが作れるという意味でもあります。
宜しくお願いします。

[上に] [前に] [次に]