学习JS弹窗

来源:互联网 发布:netbeans for php使用 编辑:程序博客网 时间:2024/05/29 09:19
 
HTML code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MasterSlaveDemo.aspx.cs" Inherits="ajax_xmlHttpRequest_MasterSlaveDemo" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>无标题页</title> <script> var xmlHttp=null; var sEvent=null; function $(id) { return document.getElementById(id); } function createXMLHttpRequest() { if(xmlHttp == null){ if(window.XMLHttpRequest) { //Mozilla 浏览器 xmlHttp = new XMLHttpRequest(); }else if(window.ActiveXObject) { // IE浏览器 try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } } } function openAjax(id) { if( xmlHttp == null) { createXMLHttpRequest(); if( xmlHttp == null) { //alert('出错'); return ; } } try { xmlHttp.open("get","MasterSlaveResult.aspx?ID="+id+"&date="+new Date(),true); xmlHttp.onreadystatechange=xmlHttpChange; xmlHttp.send(null); var div= $('divResult'); div.style.left=event.clientX+5; div.style.top=event.clientY+5; } catch(e) { } } function xmlHttpChange() { if(xmlHttp.readyState==4) { if(xmlHttp.status==200) { var div= $('divResult'); div.innerHTML= xmlHttp.responseText; div.style.display=''; div.focus(); } } } </script></head><body> <form id="form1" runat="server"> <asp:GridView ID="gv" runat="server" OnRowDataBound="gv_RowDataBound"></asp:GridView> <div id="divResult" onmouseout="this.style.display='none';" style =" border :solid 1px red; background :#f0f0f0; display :none ; position :absolute"> </div> </form></body></html>
原创粉丝点击