动态图片,可以在IE6上显示,但是用firefox浏览时 就不显示图片 本帖最后由 yaoyao159 于 2010-03-28 11:56:47 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个问题主要是因为IE,FIRFOX的标准不一样引起,IE不怎么遵循W3C标准的.JS脚本容易引发异同.name="SlideShow"改成 ID=="SlideShow"document.SlideShow改成document.getElementById("SlideShow")试下尽量用ID来标注另外去搜下关于FIREFOX和IE 的js脚本编写差异的总结文章看下! 恩恩。name="SlideShow"改成 ID=="SlideShow"document.SlideShow改成document.getElementById("SlideShow")这两个方法我都试过,不行的,不过还是谢谢你哈,呵呵。后来我在网上找了另一段关于图片切换效果的代码,转载自http://www.cnblogs.com/cloudgamer/archive/2008/05/23/1205642.html根据我的需要,我重新改了下代码:经测试,可以在IE8和firefox正常显示图片,不过因为firefox不支持滤镜效果,所以没有图片转换的效果。js代码:<script type="text/javascript">var isIE = (document.all) ? true : false;var $ = function (id) {//alert(id);//alert(document.getElementById(id)); return "string" == typeof id ? document.getElementById(id) : id; alert(string);};var Class = { create: function() { return function() { this.initialize.apply(this, arguments); } }}var Extend = function(destination, source) { for (var property in source) { destination[property] = source[property]; }}var Bind = function(object, fun) { return function() { return fun.apply(object, arguments); }}var Each = function(list, fun){ for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); }};//ie onlyvar RevealTrans = Class.create();RevealTrans.prototype = { initialize: function(container, options) { this._img = document.createElement("img"); this._a = document.createElement("a"); this._timer = null;//计时器 this.Index = 0;//显示索引 this._onIndex = -1;//当前索引 this.SetOptions(options); this.Auto = !!this.options.Auto; this.Pause = Math.abs(this.options.Pause); this.Duration = Math.abs(this.options.Duration); this.Transition = parseInt(this.options.Transition); this.List = this.options.List; this.onShow = this.options.onShow; //初始化显示区域 this._img.style.visibility = "hidden";//第一次变换时不显示红x图 this._img.style.width = this._img.style.height = "100%"; this._img.style.border = 0; this._img.onmouseover = Bind(this, this.Stop); this._img.onmouseout = Bind(this, this.Start); isIE && (this._img.style.filter = "revealTrans()"); this._a.target = "_blank";// alert("1"); $(container).appendChild(this._a).appendChild(this._img); }, //设置默认属性 SetOptions: function(options) { this.options = {//默认值 Auto: true,//是否自动切换 Pause: 1000,//停顿时间(微妙) Duration: 1,//变换持续时间(秒) Transition: 23,//变换效果(23为随机) List: [],//数据集合,如果这里不设置可以用Add方法添加 onShow: function(){}//变换时执行 }; Extend(this.options, options || {}); }, Start: function() { clearTimeout(this._timer); //如果没有数据就返回 if(!this.List.length) return; //修正Index if(this.Index < 0 || this.Index >= this.List.length){ this.Index = 0; } //如果当前索引不是显示索引就设置显示 if(this._onIndex != this.Index){ this._onIndex = this.Index; this.Show(this.List[this.Index]); } //如果要自动切换 if(this.Auto){ this._timer = setTimeout(Bind(this, function(){ this.Index++; this.Start(); }), this.Duration * 1000 + this.Pause); } }, //显示 Show: function(list) { if(isIE){ //设置变换参数 with(this._img.filters.revealTrans){ Transition = this.Transition; Duration = this.Duration; apply(); play(); } } this._img.style.visibility = ""; //设置图片属性 this._img.src = list.img; this._img.alt = ''; //设置链接 !!list["url"] ? (this._a.href = list["url"]) : this._a.removeAttribute("href"); //附加函数 this.onShow(); }, //添加变换对象 Add: function(sIimg, sText, sUrl) { this.List.push({ img: sIimg, text: sText, url: sUrl }); }, //停止 Stop: function() { clearTimeout(this._timer); }};</script>页面代码:<tr> <td width="280" height="198" > <div id="idShow" class="container"></div> <script type="text/javascript"> var r = new RevealTrans("idShow"); //添加变换对象 for(i=10;i<38;i++) { // alert(i); r.Add('image/photo/'+i+'.jpg', '', ''); r.Start(); } </script> </td> </tr> WebBrowser控件如何控制点击链接不打开IE窗口 请问如何向已绑定数据的datagridview中添加新行? 谁用过Xtreme.Suite.Pro 11.2.1 checkbox的问题 希望有高手给说一个C#版的动态代理模式的例子,200分的帖子 VS2005中在 服务器资源管理器 中建立的数据表,能把名字改了吗? VB 怎么修改成如下 C# 的数据库连接方式: (注:一定还要用VB,不能用C#) .net部署中遇到的问题。向文件夹中添加很多文件时像死机一样慢。 windows自定义日志任务类型 c#中如何创建这样的网页? 关于 查找功能 的设计 当前上下文不存在名称utility
JS脚本容易引发异同.name="SlideShow"改成 ID=="SlideShow"document.SlideShow改成document.getElementById("SlideShow")试下尽量用ID来标注另外去搜下关于FIREFOX和IE 的js脚本编写差异的总结文章看下!
name="SlideShow"改成 ID=="SlideShow"document.SlideShow改成document.getElementById("SlideShow")
这两个方法我都试过,不行的,不过还是谢谢你哈,呵呵。
后来我在网上找了另一段关于图片切换效果的代码,转载自http://www.cnblogs.com/cloudgamer/archive/2008/05/23/1205642.html
根据我的需要,我重新改了下代码:经测试,可以在IE8和firefox正常显示图片,不过因为firefox不支持滤镜效果,所以没有图片转换的效果。
js代码:<script type="text/javascript">
var isIE = (document.all) ? true : false;var $ = function (id) {
//alert(id);
//alert(document.getElementById(id));
return "string" == typeof id ? document.getElementById(id) : id;
alert(string);
};var Class = {
create: function() {
return function() { this.initialize.apply(this, arguments); }
}
}var Extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
}var Bind = function(object, fun) {
return function() {
return fun.apply(object, arguments);
}
}var Each = function(list, fun){
for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); }
};
//ie only
var RevealTrans = Class.create();
RevealTrans.prototype = {
initialize: function(container, options) {
this._img = document.createElement("img");
this._a = document.createElement("a");
this._timer = null;//计时器
this.Index = 0;//显示索引
this._onIndex = -1;//当前索引
this.SetOptions(options);
this.Auto = !!this.options.Auto;
this.Pause = Math.abs(this.options.Pause);
this.Duration = Math.abs(this.options.Duration);
this.Transition = parseInt(this.options.Transition);
this.List = this.options.List;
this.onShow = this.options.onShow;
//初始化显示区域
this._img.style.visibility = "hidden";//第一次变换时不显示红x图
this._img.style.width = this._img.style.height = "100%"; this._img.style.border = 0;
this._img.onmouseover = Bind(this, this.Stop);
this._img.onmouseout = Bind(this, this.Start);
isIE && (this._img.style.filter = "revealTrans()");
this._a.target = "_blank";
// alert("1");
$(container).appendChild(this._a).appendChild(this._img);
},
//设置默认属性
SetOptions: function(options) {
this.options = {//默认值
Auto: true,//是否自动切换
Pause: 1000,//停顿时间(微妙)
Duration: 1,//变换持续时间(秒)
Transition: 23,//变换效果(23为随机)
List: [],//数据集合,如果这里不设置可以用Add方法添加
onShow: function(){}//变换时执行
};
Extend(this.options, options || {});
},
Start: function() {
clearTimeout(this._timer);
//如果没有数据就返回
if(!this.List.length) return;
//修正Index
if(this.Index < 0 || this.Index >= this.List.length){ this.Index = 0; }
//如果当前索引不是显示索引就设置显示
if(this._onIndex != this.Index){ this._onIndex = this.Index; this.Show(this.List[this.Index]); }
//如果要自动切换
if(this.Auto){
this._timer = setTimeout(Bind(this, function(){ this.Index++; this.Start(); }), this.Duration * 1000 + this.Pause);
}
},
//显示
Show: function(list) {
if(isIE){
//设置变换参数
with(this._img.filters.revealTrans){
Transition = this.Transition; Duration = this.Duration; apply(); play();
}
}
this._img.style.visibility = "";
//设置图片属性
this._img.src = list.img; this._img.alt = '';
//设置链接
!!list["url"] ? (this._a.href = list["url"]) : this._a.removeAttribute("href");
//附加函数
this.onShow();
},
//添加变换对象
Add: function(sIimg, sText, sUrl) {
this.List.push({ img: sIimg, text: sText, url: sUrl });
},
//停止
Stop: function() {
clearTimeout(this._timer);
}
};</script>
页面代码:<tr>
<td width="280" height="198" >
<div id="idShow" class="container"></div>
<script type="text/javascript">
var r = new RevealTrans("idShow");
//添加变换对象
for(i=10;i<38;i++)
{
// alert(i);
r.Add('image/photo/'+i+'.jpg', '', '');
r.Start();
}
</script>
</td>
</tr>