在HTML页面通过webservice.htc调Webservice

该博客为转载内容,转载自https://www.cnblogs.com/evernory/archive/2004/07/13/23907.html ,涉及JavaScript相关知识。
HTML代码如下:

 

None.gif<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
None.gif
<HTML>
None.gif 
<HEAD>
None.gif  
<TITLE></TITLE>
None.gif  
<META NAME="GENERATOR" Content="Microsoft Visual Studio 7.0">
None.gif  
<Link href="../Css/style.css" rel="stylesheet"></Link>
ExpandedBlockStart.gifContractedBlock.gif  
<script language="javascript">dot.gif
InBlock.gif  
var iCallID = 0;
InBlock.gif  
InBlock.gif  
function Init()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   service.useService(
"http://ming.europe.webmatrixhosting.net/MingWService/Caculate.asmx?WSDL","Caculate");
ExpandedSubBlockEnd.gif  }

InBlock.gif  
function mathResults(result)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
// if there is an error, and the call came from the call() in init()
InBlock.gif
   if(result.error)
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
// Pull the error information from the event.result.errorDetail properties
InBlock.gif
    var xfaultcode   = result.errorDetail.code;
InBlock.gif    
var xfaultstring = result.errorDetail.string;
InBlock.gif    
var xfaultsoap   = result.errorDetail.raw;
InBlock.gif
InBlock.gif    
// Add code to handle specific error codes here
InBlock.gif
    txtResult.value = "Something Error dot.gif";
ExpandedSubBlockEnd.gif   }

InBlock.gif   
// if there was no error
InBlock.gif
   else
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
// Show the arithmetic
InBlock.gif
    //alert(intA + ' + ' + intB + " = " + result.value);
InBlock.gif
    txtResult.value = result.value;
ExpandedSubBlockEnd.gif   }

ExpandedSubBlockEnd.gif  }

InBlock.gif  
function Add(a,b)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   DisbleButton();
InBlock.gif   txtResult.value 
= "Calculating Now dot.gif";
InBlock.gif   iCallID 
= service.Caculate.callService(mathResults, "Add", a, b);
InBlock.gif   EnableButton();
ExpandedSubBlockEnd.gif  }

InBlock.gif  
function Subtract(a,b)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   DisbleButton();
InBlock.gif   txtResult.value 
= "Calculating Now dot.gif";
InBlock.gif   iCallID 
= service.Caculate.callService(mathResults, "Subtract", a, b);
InBlock.gif   EnableButton();
ExpandedSubBlockEnd.gif  }

InBlock.gif  
function Multiply(a,b)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   DisbleButton();
InBlock.gif   txtResult.value 
= "Calculating Now dot.gif";
InBlock.gif   iCallID 
= service.Caculate.callService(mathResults, "Multiply", a, b);
InBlock.gif   EnableButton();
ExpandedSubBlockEnd.gif  }

InBlock.gif  
function Divide(a,b)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   DisbleButton();
InBlock.gif   txtResult.value 
= "Calculating Now dot.gif";
InBlock.gif   iCallID 
= service.Caculate.callService(mathResults, "Divide", a, b);
InBlock.gif   EnableButton();
ExpandedSubBlockEnd.gif  }

InBlock.gif  
function DisbleButton()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   btnAdd.disabled 
= true;
InBlock.gif   btnSubtract.disabled 
= true;
InBlock.gif   btnMultiply.disabled 
= true;
InBlock.gif   btnDevide.disabled 
= true;
ExpandedSubBlockEnd.gif  }

InBlock.gif  
function EnableButton()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   btnAdd.disabled 
= false;
InBlock.gif   btnSubtract.disabled 
= false;
InBlock.gif   btnMultiply.disabled 
= false;
InBlock.gif   btnDevide.disabled 
= false;
ExpandedSubBlockEnd.gif  }

ExpandedBlockEnd.gif  
</script>
None.gif 
</HEAD>
None.gif 
<BODY onload="Init()">
None.gif  
<div id="service" style="BEHAVIOR:url(../Htc/webservice.htc)"></div>
None.gif  
<FONT face="宋体"></FONT>
None.gif  
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
None.gif   
<TR>
None.gif    
<TD align="middle" valign="center">
None.gif     
<TABLE id="Table2" cellSpacing="1" cellPadding="1" width="80%" border="0">
None.gif      
<TR>
None.gif       
<TD></TD>
None.gif      
</TR>
None.gif      
<TR>
None.gif       
<TD>float a:<INPUT id="txtA" class="text" type="text" name="txtA"></TD>
None.gif      
</TR>
None.gif      
<TR>
None.gif       
<TD>float b:<INPUT id="txtB" class="text" type="text" name="txtB"></TD>
None.gif      
</TR>
None.gif      
<TR>
None.gif       
<TD>
None.gif        
<INPUT id="btnAdd" type="button" onclick="Add(txtA.value,txtB.value)" value="Add" name="btnAdd">
None.gif        
<INPUT id="btnSubtract" type="button" onclick="Subtract(txtA.value,txtB.value)" value="Subtract" name="btnSubtract">
None.gif        
<INPUT id="btnMultiply" type="button" onclick="Multiply(txtA.value,txtB.value)" value="Multiply" name="btnMultiply">
None.gif        
<INPUT id="btnDevide" type="button" onclick="Divide(txtA.value,txtB.value)" value="Devide" name="btnDevide"></TD>
None.gif      
</TR>
None.gif      
<TR>
None.gif       
<TD>Result:<INPUT id="txtResult" class="text" type="text" name="txtResult"></TD>
None.gif      
</TR>
None.gif     
</TABLE>
None.gif    
</TD>
None.gif   
</TR>
None.gif  
</TABLE>
None.gif 
</BODY>
None.gif
</HTML>

转载于:https://www.cnblogs.com/evernory/archive/2004/07/13/23907.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值