求助。eval的使用
自学中,看到这样的语句 if(br)
{eval(lRef+ 'www_mingrisoft_com '+CMessages)
eval(lRef+ 'www_mingrisoft_com '+CloseIt); },应该如何理解?
源代码如下:
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default.aspx.cs " Inherits= "_Default " %> <!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 ">
<style type= "text/css ">
{
position:absolute;background: #eeffee;//解释框背景色
}
</STYLE>
<SCRIPT LANGUAGE= "JAVASCRIPT ">
CueMessage=new Array(5)//创建数组
CueMessage[0]= " <font color=red> <b> 欢迎光临明日科技游戏网! </b> </font> "
CueMessage[1]= " <font color=red> <b> 进入游戏公告区,您可以了解最近的公告信息! </b> </font> "
CueMessage[2]= " <font color=red> <b> 可以帮助您对本站发行的积分进行了解! </b> </font> "
CueMessage[3]= " <font color=red> <b> 来这里,您可以知道如何购买本站的产品! </b> </font> "
CueMessage[4]= " <font color=red> <b> 为玩家提供交流的社区! </b> </font> "
var br;//声明变量.用于指定浏览器
if (document.all)
{
lRef= 'document.all. '
styleRef= '.style. '
CMessages= ".innerHTML=CueMessage[num] "
CloseIt= " "
br=true
}
else
{
alert( "此效果在Netscape浏览器中不能实现! ");
}
function www_mingrisoft_com(num)
{
if(br)
{
eval(lRef+ 'www_mingrisoft_com '+CMessages)
eval(lRef+ 'www_mingrisoft_com '+CloseIt);
}
}
</SCRIPT>
</head>
<body style= "text-align: center ">
<table cellspacing= "0 " cellpadding= "0 ">
<tr>
<td style= "height: 30px ">
<a href= "http://www.mingrisoft.com " onMouseOver= "www_mingrisoft_com(0) " onMouseOut= "www_mingrisoft_com(5) " target= "_blank ">
<span style= "font-size: 11pt; color: #0000ff "> 本站首页 </span> </a>
</td>
</tr>
<tr>
<td style= "height: 30px ">
<a href= "http://www.mingrisoft.com " onMouseOver= "www_mingrisoft_com(1) " onMouseOut= "www_mingrisoft_com(5) " target= "_blank ">
<span style= "font-size: 11pt; color: #0000ff "> 游戏公告 </span> </a>
</td>
</tr>
<tr>
<td style= "height: 30px ">
<a href= "http://www.mingrisoft.com " onMouseOver= "www_mingrisoft_com(2) " onMouseOut= "www_mingrisoft_com(5) " target= "_blank ">
<span style= "font-size: 11pt; color: #0000ff; "> 积分乐园 </span> </a>
</td>
</tr>
<tr>
<td style= "height: 30px ">
<a href= "http://www.mingrisoft.com " onMouseOver= "www_mingrisoft_com(3) " onMouseOut= "www_mingrisoft_com(5) " target= "_blank ">
<span style= "font-size: 11pt; color: #0000ff "> 汇款方式 </span> </a>
</td>
</tr>
<tr>
<td style= "height: 30px ">
<a href= "http://www.mingrisoft.com " onMouseOver= "www_mingrisoft_com(4) " onMouseOut= "www_mingrisoft_com(5) " target= "_blank ">
<span style= "font-size: 11pt; color: #0000ff "> 玩家论坛 </span> </a>
</td>
</tr>
</table>
<br />
<div id= "www_mingrisoft_com " style= "left: 220px; top: 69px; width: 299px; height: 40px "> </div>
</body>
</html>
[解决办法]
eval( "alert( 'AAA ') ")
就是 alert( "AAA ")
eval是用来执行运算的,你可以理解为 run~~~