ある
2000/06/05(月) 18:40:47
掲示板でJAVASCRIPTを使おうと思ったのですが、
最後の方にあるdocument.allからはじまる行で
JAVASCRIPTのエラーが出てしまいます。
'document.all[...].style'はオブジェクトではありません。
というものです。
赤ラウンジと青ラウンジのどちらで書くか迷ったのですが、
htmlファイルの場合は正常に動いたのでこちらに書きました。
以下ちょっと長いですがJAVASVRIPTの部分です。
何かお気づきの点がありましたら教えてもらえませんでしょうか?
print "<SCRIPT LANGUAGE=\"JavaScript1.2\">\n";
print "<!-- Original: Altan \(snow\@altan.hr) -->\n";
print "<!-- Web Site:
http://www.altan.hr/snow -->\n";
print "<!-- Begin\n";
print "var no = 15; // snow number\n";
print "var speed = 10; // smaller number moves the snow faster\n";
print "var snowflake = \"images/snow0.gif\";\n";
print "var ns4up = (document.layers) ? 1 : 0; // browser sniffer\n";
print "var ie4up = (document.all) ? 1 : 0;\n";
print "var dx, xp, yp; // coordinate and position variables\n";
print "var am, stx, sty; // amplitude and step variables\n";
print "var i, doc_width = 800, doc_height = 1800;\n";
print "if (ns4up) {\n";
print "doc_width = self.innerWidth;\n";
print "//doc_height = self.innerHeight;\n";
print "} else if (ie4up) {\n";
print "doc_width = document.body.clientWidth;\n";
print "//doc_height = document.body.clientHeight;\n";
print "}\n";
print "dx = new Array();\n";
print "xp = new Array();\n";
print "yp = new Array();\n";
print "am = new Array();\n";
print "stx = new Array();\n";
print "sty = new Array();\n";
print "for (i = 0; i < no; ++ i) { \n";
print "dx[i] = 0; // set coordinate variables\n";
print "xp[i] = Math.random()*(doc_width-50); // set position variables\n";
print "yp[i] = Math.random()*doc_height;\n";
print "am[i] = Math.random()*20; // set amplitude variables\n";
print "stx[i] = 0.02 + Math.random()/10; // set step variables\n";
print "sty[i] = 0.7 + Math.random(); // set step variables\n";
print "if (ns4up) { // set layers\n";
print "if (i == 0) {\n";
print "document.write(\"<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src=\"" + snowflake + "\" border=\"0\"></layer>\");\n";
print "} else {\n";
print "document.write(\"<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src=\"" + snowflake + "\" border=\"0\"></layer>\");\n";
print " }\n";
print "} else if (ie4up) {\n";
print "if (i == 0) {\n";
print "document.write(\"<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src=\"" + snowflake + "\" border=\"0\"></div>\");\n";
print "} else {\n";
print "document.write(\"<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src=\"" + snowflake + "\" border=\"0\"></div>\");\n";
print " }\n";
print " }\n";
print "}\n";
print "function snowNS() { // Netscape main animation function\n";
print "for (i = 0; i < no; ++ i) { // iterate for every dot\n";
print "yp[i] += sty[i];\n";
print "if (yp[i] > doc_height-50) {\n";
print "xp[i] = Math.random()*(doc_width-am[i]-30);\n";
print "yp[i] = 0;\n";
print "stx[i] = 0.02 + Math.random()/10;\n";
print "sty[i] = 0.7 + Math.random();\n";
print "doc_width = self.innerWidth;\n";
print "//doc_height = self.innerHeight;\n";
print "}\n";
print "dx[i] += stx[i];\n";
print "document.layers[\"dot\"+i].top = yp[i];\n";
print "document.layers[\"dot\"+i].left = xp[i] + am[i]*Math.sin(dx[i]);\n";
print "}\n";
print "setTimeout(\"snowNS()\", speed);\n";
print "}\n";
print "function snowIE() { // IE main animation function\n";
print "for (i = 0; i < no; ++ i) { // iterate for every dot\n";
print "yp[i] += sty[i];\n";
print "if (yp[i] > doc_height-50) {\n";
print "xp[i] = Math.random()*(doc_width-am[i]-30);\n";
print "yp[i] = 0;\n";
print "stx[i] = 0.02 + Math.random()/10;\n";
print "sty[i] = 0.7 + Math.random();\n";
print "doc_width = document.body.clientWidth;\n";
print "//doc_height = document.body.clientHeight;\n";
print "}\n";
print "dx[i] += stx[i];\n";
print "document.all[\"dot\"+i].style.pixelTop = yp[i];\n";
print "document.all[\"dot\"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);\n";
print "}\n";
print "setTimeout(\"snowIE()\", speed);\n";
print "}\n";
print "if (ns4up) {\n";
print "snowNS();\n";
print "} else if (ie4up) {\n";
print "snowIE();\n";
print "}\n";
print "// End -->\n";
print "</script>\n";
長文申し訳ありません。m(_ _)m