zoukankan      html  css  js  c++  java
  • 强大兼容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/p/2550809.html
Copyright © 2011-2022 走看看