强大兼容IE6flash图片新闻切换

相比较Js的不兼容IE6 而言,flash的图片切换优势显而易见:

<table width="390" height="230" align="center" cellpadding="0" cellspacing="0" border="0">

                        <tr>

                            <td>

                   

                                <script type="text/javascript">

                                    imgUrl1 = "<%=imgUrl1%>";

                                    imgtext1 = "<%=imgtext1 %> ";

                                    imgLink1 = escape("<%=imgLink1 %> ");

                                    imgUrl2 = " <%=imgUrl2%> ";

                                    imgtext2 = "<%=imgtext2 %> ";

                                    imgLink2 =escape( "<%=imgLink2 %> ");

                                    imgUrl3 = " <%=imgUrl3%> ";

                                    imgtext3 = "<%=imgtext3 %> ";

                                    imgLink3 = escape("<%=imgLink3 %> ");

 

 

                                    var focus_width = 390;

                                    var focus_height = 230;

                                    var text_height = 26;

                                    var swf_height = focus_height + text_height;

 

                                    var pics = imgUrl1 + "|" + imgUrl2 + "|" + imgUrl3;

                                    var links = imgLink1 + "|" + imgLink2 + "|" + imgLink3;

                                    var texts = imgtext1 + "|" + imgtext2 + "|" + imgtext3;

 

                                    document.write('<object classid="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('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="images/focus.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">');

                                    document.write('<param name="menu" value="false"><param name=wmode value="opaque">');

                                    document.write('<param name="FlashVars" value="pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '">');

                                    document.write('</object>');

                                </script>

                            </td>

                        </tr>

                    </table>
后台代码:

protected string imgUrl1 = "";

    protected string imgUrl2 = "";

    protected string imgUrl3 = "";

    protected string imgtext1 = "";

    protected string imgtext2 = "";

    protected string imgtext3 = "";

    protected string imgLink1 = "";

    protected string imgLink2 = "";

    protected string imgLink3 = "";

    protected void Page_Load(object sender, EventArgs e)

    {

 

        bindToRepeaterNews();

        DataSet ds = Cms.GetList("100", 3);

        DataTable tb = ds.Tables[0];

 

 

        if (tb.Rows.Count >= 1)

        {

            if (tb.Rows[0]["fRedirect"].ToString().Equals("1"))

            {

                //imgUrl1 = String.Format("<a href=\"{0}\"><img src=\"{1}\" width=\"390\" height=\"230\" alt=\"{2}\" ;/></a>", tb.Rows[0]["fRedirectUrl"].ToString(), tb.Rows[0]["fThumbImgUrl"].ToString(), tb.Rows[0]["fTitle"].ToString());

 

                imgUrl1 = tb.Rows[0]["fThumbImgUrl"].ToString();

                imgtext1 = tb.Rows[0]["fTitle"].ToString();

                imgLink1 = tb.Rows[0]["fRedirectUrl"].ToString();;

            }

            else

            {

                //imgUrl1 = String.Format("<a href=\"xwzx.aspx?action=details&id={0}\"><img src=\"{1}\" width=\"390\" height=\"230\" alt=\"{2}\" /></a>", tb.Rows[0]["fid"].ToString(), tb.Rows[0]["fThumbImgUrl"].ToString(), tb.Rows[0]["fTitle"].ToString());

                imgUrl1 = tb.Rows[0]["fThumbImgUrl"].ToString();

                imgtext1 = tb.Rows[0]["fTitle"].ToString();

                imgLink1 = String.Format("xwzx.aspx?action=details&id={0}", tb.Rows[0]["fid"].ToString());

            }

        }

        if (tb.Rows.Count >= 2)

        {

            if (tb.Rows[0]["fRedirect"].ToString().Equals("1"))

            {

                //mImgUrl1 = String.Format("<a href=\"{0}\"><img src=\"{1}\" width=\"390\" height=\"230\" alt=\"{2}\" /></a>", tb.Rows[1]["fRedirectUrl"].ToString(), tb.Rows[1]["fThumbImgUrl"].ToString(), tb.Rows[1]["fTitle"].ToString());

                imgUrl2 = tb.Rows[1]["fThumbImgUrl"].ToString();

                imgtext2 = tb.Rows[1]["fTitle"].ToString();

                imgLink2 = tb.Rows[1]["fRedirectUrl"].ToString(); ;

            }

            else

            {

                //mImgUrl1 = String.Format("<a href=\"xwzx.aspx?action=details&id={0}\"><img src=\"{1}\" width=\"390\" height=\"230\" alt=\"{2}\" /></a>", tb.Rows[1]["fid"].ToString(), tb.Rows[1]["fThumbImgUrl"].ToString(), tb.Rows[1]["fTitle"].ToString());

                imgUrl2 = tb.Rows[1]["fThumbImgUrl"].ToString();

                imgtext2 = tb.Rows[1]["fTitle"].ToString();

                imgLink2 = String.Format("xwzx.aspx?action=details&id={0}", tb.Rows[1]["fid"].ToString());

            }

        }

        if (tb.Rows.Count >= 3)

        {

            if (tb.Rows[0]["fRedirect"].ToString().Equals("1"))

            {

                //mImgUrl2 = String.Format("<a href=\"{0}\"><img src=\"{1}\" width=\"390\" height=\"230\"  alt=\"{2}\"/></a>", tb.Rows[2]["fRedirectUrl"].ToString(), tb.Rows[2]["fThumbImgUrl"].ToString(), tb.Rows[2]["fTitle"].ToString());

                imgUrl3 = tb.Rows[2]["fThumbImgUrl"].ToString();

                imgtext3 = tb.Rows[2]["fTitle"].ToString();

                imgLink3 = tb.Rows[2]["fRedirectUrl"].ToString(); ;

            }

            else

            {

                //mImgUrl2 = String.Format("<a href=\"xwzx.aspx?action=details&id={0}\"><img src=\"{1}\" width=\"390\" height=\"230\" alt=\"{2}\" /></a>", tb.Rows[2]["fid"].ToString(), tb.Rows[2]["fThumbImgUrl"].ToString(), tb.Rows[2]["fTitle"].ToString());

                imgUrl3 = tb.Rows[2]["fThumbImgUrl"].ToString();

                imgtext3 = tb.Rows[2]["fTitle"].ToString();

                imgLink3 = String.Format("xwzx.aspx?action=details&id={0}", tb.Rows[2]["fid"].ToString());

            }

        }

比较一下之前的拼凑,方便多了,至于解决IE6兼容的问题,网上的说法很多,但是似乎没什么用,主要问题还是出在<a></a>标签上。

但是以上的方法可以一劳永逸,当然,也是相对于大部分客户而言。新闻图片,新闻标题,新闻链接,无非就是这三样,然后就是图片切换样式,时间等等。

 

转载于:https://www.cnblogs.com/howie/archive/2012/06/15/2550809.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值