javascript新手遇到问题:下面程序错哪里了?字体大小变化的!
<html><head></head><body><scriptlanguage="javascript">varspeed=20;varcycledelay=1000;...
<html>
<head>
</head>
<body>
<script language="javascript">
var speed=20;
var cycledelay=1000;
var maxsize=48;
var thismsg2=new initArray(
"从小到大... ...<br>还会从大到小... ...",
"<a href=#><b><i> 可以加粗加斜加链接... ...</i></b></a>",
"<img src=images/left.gif>还可以加图片:)<img scr=images/right.gif>",
"嘿嘿... ...酷吧!");
var x=0;
var y=0;
var thismsg,size;
var esize="";
function initArray(){
this.length=initArray.arguments.length;
for(var i=0;i<this.length;i++){
this[i]=initArray.arguments[i];
}
}
if(navigator.appName="Netscape")
document.write('<layer id="msgblk"></layer><br>');
if(navigator.appVersion.indexOf("MSIE")!=-1)
document.write('<span id="msgblk"></span><br>');
function big(){
thismsg=thismsg2[y];
if(x<maxsize){
x++;
setTimeout("big()",speed);
}
else setTimeout("small()",cycledelay);
if(navigator.appName="Netscape"){
size="<font point-size=""+x+"pt">";
document.msgblk.document.write(size+"<center>"+thismsg+"</center>"+esize);
document.msgblk.document.close();
}
if(navigator.appVersion.indexOf("MSIE")!=-1){
msgblk.innerHTML="<center>"+thismsg+"</center>";
msgblk.style.fontSize=x+'px';
}
}
function small(){
if(x>1){
x--;
setTimeout("small()",speed);
}
else{
setTimeout("big()",cycledelay);
y++;
if(y>thismsg2.length-1) y=0;
}
if(navigator.appName="Netscape"){
size="<font point-size=""+x+"pt">";
document.msgblk.document.write(size+"<center>"+thismsg+"</center>"+esize);
document.msgblk.document.close();
}
if(navigator.appVersion.indexOf("MSIE")!=-1){
msgblk.innerHTML="<center>"+thismsg+"</center>";
msgblk.style.fontSize=x+'px';
}
}
setTimeout("big()",speed);
</script>
</body>
</html> 展开
<head>
</head>
<body>
<script language="javascript">
var speed=20;
var cycledelay=1000;
var maxsize=48;
var thismsg2=new initArray(
"从小到大... ...<br>还会从大到小... ...",
"<a href=#><b><i> 可以加粗加斜加链接... ...</i></b></a>",
"<img src=images/left.gif>还可以加图片:)<img scr=images/right.gif>",
"嘿嘿... ...酷吧!");
var x=0;
var y=0;
var thismsg,size;
var esize="";
function initArray(){
this.length=initArray.arguments.length;
for(var i=0;i<this.length;i++){
this[i]=initArray.arguments[i];
}
}
if(navigator.appName="Netscape")
document.write('<layer id="msgblk"></layer><br>');
if(navigator.appVersion.indexOf("MSIE")!=-1)
document.write('<span id="msgblk"></span><br>');
function big(){
thismsg=thismsg2[y];
if(x<maxsize){
x++;
setTimeout("big()",speed);
}
else setTimeout("small()",cycledelay);
if(navigator.appName="Netscape"){
size="<font point-size=""+x+"pt">";
document.msgblk.document.write(size+"<center>"+thismsg+"</center>"+esize);
document.msgblk.document.close();
}
if(navigator.appVersion.indexOf("MSIE")!=-1){
msgblk.innerHTML="<center>"+thismsg+"</center>";
msgblk.style.fontSize=x+'px';
}
}
function small(){
if(x>1){
x--;
setTimeout("small()",speed);
}
else{
setTimeout("big()",cycledelay);
y++;
if(y>thismsg2.length-1) y=0;
}
if(navigator.appName="Netscape"){
size="<font point-size=""+x+"pt">";
document.msgblk.document.write(size+"<center>"+thismsg+"</center>"+esize);
document.msgblk.document.close();
}
if(navigator.appVersion.indexOf("MSIE")!=-1){
msgblk.innerHTML="<center>"+thismsg+"</center>";
msgblk.style.fontSize=x+'px';
}
}
setTimeout("big()",speed);
</script>
</body>
</html> 展开
2个回答
2011-08-08
展开全部
呵呵,有三处错误!!!
1、2处双引号匹配错误,
2、不是,document.msgblk.document.write而是:document.getElementById('msgblk').innerHTML =
帮你做好了,看效果吧,谢谢哦,多给点分数吧,^_*
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script language="javascript">
var speed=20;
var cycledelay=1000;
var maxsize=48;
var thismsg2=new initArray(
"从小到大... ...<br>还会从大到小... ...",
"<a href=#><b><i> 可以加粗加斜加链接... ...</i></b></a>",
"<img src=images/left.gif>还可以加图片:)<img scr=images/right.gif>",
"嘿嘿... ...酷吧!");
var x=0;
var y=0;
var thismsg,size;
var esize="";
function initArray(){
this.length=initArray.arguments.length;
for(var i=0;i<this.length;i++){
this[i]=initArray.arguments[i];
}
}
if(navigator.appName="Netscape")
document.write('<layer id="msgblk"></layer><br>');
if(navigator.appVersion.indexOf("MSIE")!=-1)
document.write('<span id="msgblk"></span><br>');
function big(){
thismsg=thismsg2[y];
if(x<maxsize){
x++;
setTimeout("big()",speed);
}
else setTimeout("small()",cycledelay);
if(navigator.appName="Netscape"){
size='<font point-size="'+ x + 'pt">';
document.getElementById('msgblk').innerHTML = size+"<center>"+thismsg+"</center>"+esize ;
//document.msgblk.document.close();
}
if(navigator.appVersion.indexOf("MSIE")!=-1){
msgblk.innerHTML="<center>"+thismsg+"</center>";
msgblk.style.fontSize=x+'px';
}
}
function small(){
if(x>1){
x--;
setTimeout("small()",speed);
}
else{
setTimeout("big()",cycledelay);
y++;
if(y>thismsg2.length-1) y=0;
}
if(navigator.appName="Netscape"){
size='<font point-size="'+x+'pt">';
document.msgblk.document.write(size+"<center>"+thismsg+"</center>"+esize);
document.msgblk.document.close();
}
if(navigator.appVersion.indexOf("MSIE")!=-1){
msgblk.innerHTML="<center>"+thismsg+"</center>";
msgblk.style.fontSize=x+'px';
}
}
setTimeout("big()",speed);
</script>
</body>
</html>
1、2处双引号匹配错误,
2、不是,document.msgblk.document.write而是:document.getElementById('msgblk').innerHTML =
帮你做好了,看效果吧,谢谢哦,多给点分数吧,^_*
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script language="javascript">
var speed=20;
var cycledelay=1000;
var maxsize=48;
var thismsg2=new initArray(
"从小到大... ...<br>还会从大到小... ...",
"<a href=#><b><i> 可以加粗加斜加链接... ...</i></b></a>",
"<img src=images/left.gif>还可以加图片:)<img scr=images/right.gif>",
"嘿嘿... ...酷吧!");
var x=0;
var y=0;
var thismsg,size;
var esize="";
function initArray(){
this.length=initArray.arguments.length;
for(var i=0;i<this.length;i++){
this[i]=initArray.arguments[i];
}
}
if(navigator.appName="Netscape")
document.write('<layer id="msgblk"></layer><br>');
if(navigator.appVersion.indexOf("MSIE")!=-1)
document.write('<span id="msgblk"></span><br>');
function big(){
thismsg=thismsg2[y];
if(x<maxsize){
x++;
setTimeout("big()",speed);
}
else setTimeout("small()",cycledelay);
if(navigator.appName="Netscape"){
size='<font point-size="'+ x + 'pt">';
document.getElementById('msgblk').innerHTML = size+"<center>"+thismsg+"</center>"+esize ;
//document.msgblk.document.close();
}
if(navigator.appVersion.indexOf("MSIE")!=-1){
msgblk.innerHTML="<center>"+thismsg+"</center>";
msgblk.style.fontSize=x+'px';
}
}
function small(){
if(x>1){
x--;
setTimeout("small()",speed);
}
else{
setTimeout("big()",cycledelay);
y++;
if(y>thismsg2.length-1) y=0;
}
if(navigator.appName="Netscape"){
size='<font point-size="'+x+'pt">';
document.msgblk.document.write(size+"<center>"+thismsg+"</center>"+esize);
document.msgblk.document.close();
}
if(navigator.appVersion.indexOf("MSIE")!=-1){
msgblk.innerHTML="<center>"+thismsg+"</center>";
msgblk.style.fontSize=x+'px';
}
}
setTimeout("big()",speed);
</script>
</body>
</html>
追问
没有效果!你这个没有该对!
追答
悲剧啊,我再 Firefox 下面测试了。难道你是IE,?我修正一下
var speed = 20;
var cycledelay = 1000;
var maxsize = 48;
var thismsg2 = new initArray(
"从小到大... ...还会从大到小... ...",
" 可以加粗加斜加链接... ...",
"还可以加图片:)",
"嘿嘿... ...酷吧!");
var x = 0;
var y = 0;
var thismsg,
size;
var esize = "";
function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i ');
function big() {
thismsg = thismsg2[y];
if (x ';
document.getElementById('msgblk').innerHTML = size + "" + thismsg + "" + esize;
document.getElementById('msgblk').style.fontSize = x + 'px';
}
function small() {
if (x > 1) {
x--;
setTimeout("small()", speed);
}
else {
setTimeout("big()", cycledelay);
y++;
if (y > thismsg2.length - 1) y = 0;
}
msgblk.innerHTML = "" + thismsg + "";
msgblk.style.fontSize = x + 'px';
}
setTimeout("big()", speed);
var getPositionLite = function(el) {
var x = 0,
y = 0;
while (el) {
x += el.offsetLeft || 0;
y += el.offsetTop || 0;
el = el.offsetParent
}
return {
x: x,
y: y
}
};
2011-08-09
展开全部
是 IE 兼容性问题。楼上已经弄好了,但是伐不出去代码了,他让我帮忙发一下,你把分数给他就可以了。
看代码,兼容 IE,FIREFOX 。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script language="javascript">
var speed = 20;
var cycledelay = 1000;
var maxsize = 48;
var thismsg2 = new initArray(
"从小到大... ...<br>还会从大到小... ...",
"<a href=#><b><i> 可以加粗加斜加链接... ...</i></b></a>",
"<img src=images/left.gif>还可以加图片:)<img scr=images/right.gif>",
"嘿嘿... ...酷吧!");
var x = 0;
var y = 0;
var thismsg,
size;
var esize = "";
function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
}
}
document.write('<span id="msgblk"></span><br>');
function big() {
thismsg = thismsg2[y];
if (x < maxsize) {
x++;
setTimeout("big()", speed);
}
else setTimeout("small()", cycledelay);
size = '<font point-size="' + x + 'pt">';
document.getElementById('msgblk').innerHTML = size + "<center>" + thismsg + "</center>" + esize;
document.getElementById('msgblk').style.fontSize = x + 'px';
}
function small() {
if (x > 1) {
x--;
setTimeout("small()", speed);
}
else {
setTimeout("big()", cycledelay);
y++;
if (y > thismsg2.length - 1) y = 0;
}
msgblk.innerHTML = "<center>" + thismsg + "</center>";
msgblk.style.fontSize = x + 'px';
}
setTimeout("big()", speed);
var getPositionLite = function(el) {
var x = 0,
y = 0;
while (el) {
x += el.offsetLeft || 0;
y += el.offsetTop || 0;
el = el.offsetParent
}
return {
x: x,
y: y
}
};
</script>
</body>
</html>
看代码,兼容 IE,FIREFOX 。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script language="javascript">
var speed = 20;
var cycledelay = 1000;
var maxsize = 48;
var thismsg2 = new initArray(
"从小到大... ...<br>还会从大到小... ...",
"<a href=#><b><i> 可以加粗加斜加链接... ...</i></b></a>",
"<img src=images/left.gif>还可以加图片:)<img scr=images/right.gif>",
"嘿嘿... ...酷吧!");
var x = 0;
var y = 0;
var thismsg,
size;
var esize = "";
function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
}
}
document.write('<span id="msgblk"></span><br>');
function big() {
thismsg = thismsg2[y];
if (x < maxsize) {
x++;
setTimeout("big()", speed);
}
else setTimeout("small()", cycledelay);
size = '<font point-size="' + x + 'pt">';
document.getElementById('msgblk').innerHTML = size + "<center>" + thismsg + "</center>" + esize;
document.getElementById('msgblk').style.fontSize = x + 'px';
}
function small() {
if (x > 1) {
x--;
setTimeout("small()", speed);
}
else {
setTimeout("big()", cycledelay);
y++;
if (y > thismsg2.length - 1) y = 0;
}
msgblk.innerHTML = "<center>" + thismsg + "</center>";
msgblk.style.fontSize = x + 'px';
}
setTimeout("big()", speed);
var getPositionLite = function(el) {
var x = 0,
y = 0;
while (el) {
x += el.offsetLeft || 0;
y += el.offsetTop || 0;
el = el.offsetParent
}
return {
x: x,
y: y
}
};
</script>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询