我有一个方法,可以从and服务中提取html,并在一系列弹出窗口中显示此信息。为此,我编写了一个javascript来创建弹出窗口:
function dynamicPopup(title, HTMLstring) {
newWindow = window.open();
newDocument = newWindow.document;
newDocument.write(HTMLstring);
newDocument.title = title;
};I循环遍历结果,为从The服务返回的每个对象调用以下内容。
Page.ClientScript.RegisterStartupScript(this.GetType(), DateTime.Now.ToString(), resultMessage, true);问题是,当只返回几个弹出式窗口时,它是有效的,但如果返回15个弹出式窗口,则只显示其中的8-10个。
作为一个创可贴,我在RegisterStartupScript之后添加了等待,这似乎工作得很好,但结果是交付时间变慢了。有没有人知道解决这个问题的其他方法?
发布于 2013-07-18 02:13:07
不是在一个循环中调用多个Page.ClientScript.RegisterStartupScript,而是首先构造需要运行的脚本(例如,使用StringBuilder,组合以‘;’分隔的多个resultMessage ),然后只调用Page.ClientScript.RegisterStartupScript一次来执行结果字符串。
发布于 2013-07-18 02:08:00
我建议你使用Guid,以便用key来标识你的脚本
Guid.NewGuid().ToString()所以
Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), resultMessage, true);https://stackoverflow.com/questions/17707034
复制相似问题