ajax 实现动态图片切换

index.aspx

<script>
       
         //创建XMLHttpRequest对象       
                var request = false;
                try {
                 request = new XMLHttpRequest();
                } catch (trymicrosoft) {
                 try {
                 request = new ActiveXObject("Msxml2.XMLHTTP");
                 } catch (othermicrosoft) {
                 try {
                 request = new ActiveXObject("Microsoft.XMLHTTP");
                 } catch (failed) {
                 request = false;
                 }
                 }
                }
                if (!request)alert("Error initializing XMLHttpRequest!");
                //获取信息
         
                 var url = "FlashImage.aspx";   //跳转到操作页面
                 request.open("GET", url, true);
                 request.onreadystatechange = updatePage;
                 request.send(null);
           
                var str;
               
                //更新页面
                function updatePage() {
                 if (request.readyState == 4) {
                 if (request.status == 200) {
                  str= request.responseText;   //操作页面返回的值
                 }else if(request.status == 404) {
                 alert ("Requested URL is not found.");
                 } else if (request.status == 403) {
                 alert("Access denied.");
                 } else
                 alert("status is " + request.status);
                 }
                }
            
             if(str=="" || str==null)
             {
                location .reload();
             }
               var strrt=str.split('@');
               var pics;
               var texts;
        
               pics=strrt[1];
               texts=strrt[0];
            

             var focus_width=425
             var focus_height=227
             var text_height=18
             var swf_height = focus_height+text_height

             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/focus1.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+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
             document.write('</object>');


       </script>

 

FlashImage.aspx:   //在此页面读取数据

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FlashImage.aspx.cs" Inherits="FlashImage" %>

     <%
  System.Collections.Generic.IList<PipeModels.Flash> listurl = PipeBLL.FlashManager.GetAllFlashes();
     string str="";
     string str2 = "";    
     for (int t = 0; t < listurl.Count; t++)
     {
         string imgtext1 = listurl[t].Title;
         string imgUrl1 = listurl[t].Url;

             str = str + imgtext1 + "|";
             str2 += imgUrl1 + "|";
            
     }
     string strr = str.Substring(0, str.Length - 1);

     string strr2 = str2.Substring(0, str2.Length - 1);
     Response.Write(strr + "@" + strr2);  
  %>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值