问题描述
有哪位高手告诉我一下,怎么让火狐浏览器兼容js?例如这段代码为什么在ie中起作用,而在火狐中没有反映?<SCRIPTtype=text/javascript>varpic_width=700;//图片宽度varpic_height=225;//图片高度varbutton_pos=2;//按扭位置1左2右3上4下varstop_time=5000;//图片停留时间(1000为1秒钟)varshow_text=0;//是否显示文字标签1显示0不显示vartxtcolor="000000";//文字色varbgcolor="DDDDDD";//背景色varimag=newArray();varlink=newArray();vartext=newArray();imag[1]="http://image.pojaa.com/lj/h/attachment/201005/18/8147884_12741864081XQP.jpg";link[1]="";text[1]="";imag[2]="http://image.pojaa.com/lj/h/attachment/201005/18/8147884_1274186485uxAy.jpg";link[2]="";text[2]="";imag[3]="http://image.pojaa.com/lj/h/attachment/201005/18/8147884_1274186487Yey2.jpg";link[3]="";text[3]="";imag[4]="http://image.pojaa.com/lj/h/attachment/201005/18/8147884_1274186487VeCh.jpg";link[4]="";text[4]="";imag[5]="http://image.pojaa.com/lj/h/attachment/201005/18/8147884_1274186489lu66.jpg";link[5]="";text[5]="";//可编辑内容结束varswf_height=show_text==1?pic_height+20:pic_height;varpics="",links="",texts="";for(vari=1;i<imag.length;i++){pics=pics+("|"+imag[i]);links=links+("|"+link[i]);texts=texts+("|"+text[i]);}pics=pics.substring(1);links=links.substring(1);texts=texts.substring(1);document.write('<objectclassid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cabversion=6,0,0,0"width="'+pic_width+'"height="'+swf_height+'">');document.write('<paramname="movie"value="focus.swf">');document.write('<paramname="quality"value="high"><paramname="wmode"value="opaque">');document.write('<paramname="FlashVars"value="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'">');document.write('<embedsrc="images/top/flash/focus.swf"FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'"quality="high"width="'+pic_width+'"height="'+swf_height+'"allowScriptAccess="sameDomain"type="application/x-shockwave-flash"pluginspage="http://www.macromedia.com/go/getflashplayer"/>');document.write('</object>');</SCRIPT>
解决方案
解决方案二:
用firebug调试看是哪错了
解决方案三:
引用1楼rambosir的回复:
用firebug调试看是哪错了
自己也不是很懂js,写的时候就用firebug看,也能设置断点,执行。
解决方案四:
感觉是这里写错了document.write('<embedsrc="images/top/flash/focus.swf"FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'"quality="high"width="'+pic_width+'"height="'+swf_height+'"allowScriptAccess="sameDomain"type="application/x-shockwave-flash"pluginspage="http://www.macromedia.com/go/getflashplayer"/>');
ff识别的是embed标签,你改改这里。
解决方案五:
这样写document.write('<objecttype="application/x-shockwave-flash"data="http://www.xcwljy.cn/images/slide.swf"width="'+focus_width+'"height="'+swf_height+'">');document.write('<paramname="movie"value="http://www.xcwljy.cn/images/slide.swf"/>');document.write('<paramname="allowScriptAcess"value="sameDomain"/>');document.write('<paramname="quality"value="best"/>');document.write('<paramname="bgcolor"value="#E5ECF4"/>');document.write('<paramname="scale"value="noScale"/>');document.write('<paramname="menu"value="false">');document.write('<paramname="wmode"value="opaque"/>');document.write('<paramname="FlashVars"value="playerMode=embedded&pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"/>');document.write('</object>');
其中的变量名字自己替换
解决方案六:
下面是我在用的一段代码,可以正常显示在ff下。document.write('<objectclassid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"width="'+focus_width+'"height="'+swf_height+'">');document.write('<paramname="allowScriptAccess"value="sameDomain"><paramname="movie"value="images/focus1.swf"><paramname="quality"value="high"><paramname="bgcolor"value="#F0F0F0">');document.write('<paramname="menu"value="false"><paramname=wmodevalue="opaque">');document.write('<paramname="FlashVars"value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');document.write('<embedwidth="'+focus_width+'"height="'+swf_height+'"align="middle"pluginspage="http://www.macromedia.com/go/getflashplayer"type="application/x-shockwave-flash"allowscriptaccess="always"name="photo_player"quality="high"wmode="opaque"flashvars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"src="images/focus1.swf"></embed>');document.write('</object>');</script>
解决方案七:
引用4楼net_lover的回复:
这样写JScriptcodedocument.write('<objecttype="application/x-shockwave-flash"data="http://www.xcwljy.cn/images/slide.swf"width="'+focus_width+'"height="'+swf_height+'">');document.w……
不行啊,老哥。QQ多少啊?能给我解决一下吗
解决方案八:
<scripttype="text/javascript">imgUrl1="images/news/01.jpg";imgtext1="反反复复1"imgLink1=escape("News.action?nContent.news_id=1");imgUrl2="images/news/02.jpg";imgtext2="反反复复2"imgLink2=escape("News.action?nContent.news_id=2");imgUrl3="images/news/03.jpg";imgtext3="反反复复3"imgLink3=escape("News.action?nContent.news_id=3");imgUrl4="images/news/04.jpg";imgtext4="反反复复4"imgLink4=escape("News.action?nContent.news_id=4");imgUrl5="images/news/01.jpg";imgtext5="反反复复5"imgLink5=escape("News.action?nContent.news_id=6");varfocus_width=230varfocus_height=171vartext_height=18varswf_height=focus_height+text_heightvarpics=imgUrl1+"|"+imgUrl2+"|"+imgUrl3+"|"+imgUrl4+"|"+imgUrl5varlinks=imgLink1+"|"+imgLink2+"|"+imgLink3+"|"+imgLink4+"|"+imgLink5vartexts=imgtext1+"|"+imgtext2+"|"+imgtext3+"|"+imgtext4+"|"+imgtext5document.write('<objectclassid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"width="'+focus_width+'"height="'+swf_height+'">');document.write('<paramname="allowScriptAccess"value="sameDomain"><paramname="movie"value="images/focus1.swf"><paramname="quality"value="high"><paramname="bgcolor"value="#F0F0F0">');document.write('<paramname="menu"value="false"><paramname=wmodevalue="opaque">');document.write('<paramname="FlashVars"value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');document.write('<embedwidth="'+focus_width+'"height="'+swf_height+'"align="middle"pluginspage="http://www.macromedia.com/go/getflashplayer"type="application/x-shockwave-flash"allowscriptaccess="always"name="photo_player"quality="high"wmode="opaque"flashvars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"src="images/focus1.swf"></embed>');document.write('</object>');</script>
这可是在ff浏览器下打开复制的源代码,你把最上面的5个图链接及显示信息改掉,下面的focus1.swf改掉,在试试吧。不行我也无语了
解决方案九:
火狐是目前最支持js的浏览器,看看是不是你的那里写错了,用firebug调试是个不错的选择
解决方案十:
学习了~~~~~~~~~~~~~~~~~~~