为了引用Web Service,首先要在页面中添加以下客户端脚本:
用来显示和添加message的调用如下,对于每个方法的调用需要三个参数,分别是:Web Service方法的参数、调用成功后的回调函数、调用超时的回调函数。<scriptlanguage="JavaScript"src="ChatService.asmx/js"/>
functionGetMsg(){AtlsChat.ChatService.GetConversation("",//paramsOnComplete,//CompleteeventOnTimeout//Timeoutevent);returnfalse;}functionAdd(){
document.getElementById('info').innerHTML
='<spanstyle="background-color:yellow"> posting </span>';
AtlsChat.ChatService.Add(
document.getElementById('inputName').value.replace('\t',' ')+'\t'+document.getElementById('inputMsg').value.replace('\t',' '),
GetMsg,
OnTimeout
);
returnfalse;
}
functionOnComplete(result)
document.getElementById('msg').innerHTML=result;
document.getElementById('info').innerHTML="";
}
functionOnTimeout(result)
{
document.getElementById('info').innerHTML="timeout";
}
最后,需要在页面中引用Atlas提供的几个js:
<atlas:ScriptID="Script1"runat="server"Path="~/ScriptLibrary/AtlasCompat.js"Browser="Mozilla"/><atlas:ScriptID="Script2"runat="server"Path="~/ScriptLibrary/AtlasCompat.js"Browser="Firefox"/>
<atlas:ScriptID="Script3"runat="server"Path="~/ScriptLibrary/AtlasCompat.js"Browser="AppleMAC-Safari"/>
<atlas:ScriptID="Script4"runat="server"Path="~/ScriptLibrary/AtlasCore.js"/>
<atlas:ScriptID="Script5"runat="server"Path="~/ScriptLibrary/AtlasCompat2.js"Browser="AppleMAC-Safari"/>
<scripttype="text/xml-script"><pagexmlns:script="http://schemas.microsoft.com/xml-script/2005">
<references><!--Repaththefollowingsrcattributes,usingregularclientrelativepathsasnecessary-->
<addsrc="ScriptLibrary/AtlasUI.js"/><addsrc="ScriptLibrary/AtlasControls.js"/></references>
<components></components></page></script>
Atlas的官方网站是http://beta.asp.net/default.aspx?tabindex=7&tabid=47,虽然提供了对非IE浏览器的支持,但是在Firefox中更新div会有刷新的感觉,在Mac的Safari上也根本就不work 。