如果我有这样的脚本:
<script type="text/javascript" src="//www.gmodules.com/ig/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/100080069921643878012/facebook.xml&up_useNewFB_p=1&up_showPopUp2_p=true&synd=open&w=320&h=500&title=Facebook&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>我想在我的.cs代码中的特定时间执行这个脚本,该怎么做呢?
发布于 2012-03-08 17:07:17
string rowTestHide = @"<script type="text/javascript" src="//www.gmodules.com/ig/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/100080069921643878012/facebook.xml&up_useNewFB_p=1&up_showPopUp2_p=true&synd=open&w=320&h=500&title=Facebook&
border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>";
ClientScript.RegisterStartupScript(this.GetType(),"rowTest", rowTestHide);发布于 2012-03-08 17:10:48
尝试使用以下代码,
Page.ClientScript.RegisterClientScriptInclude("MyScript", "<script type="text/javascript" src="//www.gmodules.com/ig/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/100080069921643878012/facebook.xml&up_useNewFB_p=1&up_showPopUp2_p=true&synd=open&w=320&h=500&title=Facebook&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>");发布于 2012-03-08 23:21:51
目前要做到这一点的唯一真正的方法(不使用SignalR之类的东西)是实现一个轮询系统。
你必须有一个Ajax调用,它每隔xxx秒向你的服务器发出一个请求,使用如下代码:
window.setTimeout(function(){ /* do ajax request */ }, 5000);
它将每5秒运行一次。
如果从DB返回所需的结果,则必须以编程方式将所需的脚本块注入到页面中。
看看这个:jQuery AJAX polling for JSON response, handling based on AJAX result or JSON content
https://stackoverflow.com/questions/9615033
复制相似问题