找回密码
 立即注册
搜索
查看: 268|回复: 4

求教一段javascript的语法问题~~~~~

[复制链接]

1678

主题

5167

回帖

9302

积分

荣誉版主

沉痛悼念小于……

积分
9302
发表于 2004-2-26 20:36:35 | 显示全部楼层 |阅读模式
我想写一段代码,作用是好像论坛PM这样的功能,收到别人发给你的短信的时候,会自动弹出对话框提醒:

首先数据库存在一个MessageFlag的字段
值可能是0或者1(没新的短信的时候是0,有新的短信是1)

.....(打开数据库)
GBL_CHK_MessageFlag = Rs(6)(从数据库读出MessageFlag的值)

......
<script language="javascript">
window.setTimeout("getMessage()", 2000) 每2秒调用一次getMessage()
function getMessage()
{
var Message = "<%=GBL_CHK_MessageFlag%>"; 这句话是想获得ASP中GBL_CHK_MessageFlag的值.不过我这样写语法应该是错误的,所以我想知道这句应该怎么改,才能获得GBL_CHK_MessageFlag的值?
}

</script>

<%If Message = 1 or Message = True Then %> 当检查到Message=1或者是"真",就调用下面的JavaScript.当然,这句语法也是错误的,请问怎么样写,才能在ASP里面获取刚才JAVA里面Message的值呢?

<script language="JavaScript">
var msg = window.confirm("您有新的消息,请注意查询!");
if (msg) { window.open ('<%=DEF_BBS_HomeUrl%>User/MyInfoBox.asp');
}
</script>

.......

或者大家还有什么好的解决方法,给个例子,谢谢~~~

1678

主题

5167

回帖

9302

积分

荣誉版主

沉痛悼念小于……

积分
9302
 楼主| 发表于 2004-2-28 17:02:38 | 显示全部楼层
经过努力,代码更正为:

<script language="javascript">
window.setTimeout("getMessage()", 2000);
function getMessage()
{
var Message = <%=GBL_CHK_MessageFlag%>  
  { If (Message = 1 );
var msg = window.confirm("您有新的消息,请注意查询!");
if (msg) { window.open ('User/MyInfoBox.asp');
         }
   }
}
</script>

运行不会出错

Message 的值也的确从数据库得到1

可惜就是运行了后一点反应都没有



不会有窗口弹出来
回复

使用道具 举报

11

主题

414

回帖

573

积分

高级会员

积分
573
发表于 2004-2-29 13:23:13 | 显示全部楼层
用隐藏帧也可实现:

test.htm:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<iframe src="pm.asp" width="0" height="0"></iframe>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>fsdfsfsd</td>
  </tr>
  <tr>
    <td>fdasfadsf</td>
  </tr>
  <tr>
    <td>sdafdasf</td>
  </tr>
  <tr>
    <td>ssafsfs</td>
  </tr>
</table>
</body>
</html>

pm.asp:
<HTML>
        <HEAD>
                <title>bottom</title>
                <META HTTP-EQUIV="Refresh" content="5; URL=pm.asp">
                <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
        </HEAD>
        <body>
<%
      '数据检索......
      GBL_CHK_MessageFlag=1
  %>
<script language="javascript">
  var Message =<%=GBL_CHK_MessageFlag%>
  if(Message=1)
  {
   var msg = window.confirm("您有新的消息,请注意查询!");
   if (msg) { window.open ('User/MyInfoBox.asp'); }
   }
</script>

        </body>
</HTML>
回复

使用道具 举报

1678

主题

5167

回帖

9302

积分

荣誉版主

沉痛悼念小于……

积分
9302
 楼主| 发表于 2004-2-29 19:57:45 | 显示全部楼层
非常感谢大侠的帮忙~~~:) 已经成功了~~~
回复

使用道具 举报

327

主题

3264

回帖

3641

积分

荣誉版主

积分
3641
发表于 2004-3-1 08:42:09 | 显示全部楼层
呵呵,是啥原因呀?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|海浩社区

GMT+8, 2025-9-22 20:21 , Processed in 0.077199 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表