Javascript在Internet Explorer中运行良好,但不适用于Mozila [英] Javascript works well in Internet Explorer but doesn't Mozila

查看:79
本文介绍了Javascript在Internet Explorer中运行良好,但不适用于Mozila的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它显示适用于Internet Explorer但无法使用mozila和opera



It displays works well with Internet Explorer but fails to work with mozila and opera

<html>

<head>

<script language="JavaScript1.2">

var size = 25;
var speed_between_messages=1500  //in miliseconds


var tekst = new Array()
{
tekst[0] = "Welcome";
tekst[1] = "Home";
tekst[2] = "Feel";
tekst[3] = "Free";
}
var klaar = 0;
var s = 0;
var veran =0;
var tel = 0;
function bereken(i,Lengte)
{
return (size*Math.abs( Math.sin(i/(Lengte/3.14))) );
}

function motor(p)
{
var output = "";
for(w = 0;w < tekst[s].length - klaar+1; w++)

{

q = bereken(w/2 + p,16);

if (q > size - 0.5)
{klaar++;}
if (q < 5)

{tel++;

if (tel > 1)
{
tel = 0;
if (veran == 1)
{
veran = 0;
s++;
if ( s == tekst.length)
{s = 0;}
p = 0;
if (window.loop)
{clearInterval(loop)}
loop = motor();
}
}
}
output += "<font style='font-size: "+ q +"pt'>" +tekst[s].substring(w,w+1)+ "</font>";
}
for(k=w;k<klaar+w;k++)

{

output += "<font style='font-size: " + size + "pt'>" +tekst[s].substring(k,k+1)+ "</font>";
}
idee.innerHTML = output;
}

function startmotor(p){
if (!document.all)
return
var loop = motor(p);
if (window.time)
{clearInterval(time)}
if (klaar == tekst[s].length)
{
klaar = 0;
veran = 1;
tel = 0;
var time = setTimeout("startmotor(" +(p+1) + ")", speed_between_messages);
}else
{
var time =setTimeout("startmotor(" +(p+1) + ")", 50);
}

}

</script>

<div ID="idee"></div>
 </head>

 <body onload="startmotor(0)">
 </body>

 </html>

推荐答案

只需删除此部分:



Just remove this part:

if (!document.all)
return

< br b> b b b b b b b b b b b b b b b ://getfirebug.com/target =_ blanktitle =新窗口> ^ ],一个Firefox扩展,允许您调试脚本(我相信Opera也内置了开发人员工具) )。使用它,JavaScript控制台显示以下消息:





For future reference, make sure you download Firebug[^], a Firefox extension which allows you to debug your scripts (and I do believe Opera has developer tools built in as well). Using that, the JavaScript console showed this message:

Non-standard document.all property was used. Use W3C standard document.getElementById() instead.
if (!document.all)





因为你没有使用 document.all 在其他任何地方,删除它确保脚本有效。



As you're not using document.all anywhere else, removing it makes sure the script works.


这篇关于Javascript在Internet Explorer中运行良好,但不适用于Mozila的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆