问题ScriptManager.RegisterClientScriptBlock和jQuery在Internet Explorer 8 [英] Problem with ScriptManager.RegisterClientScriptBlock and jQuery in Internet Explorer 8

查看:201
本文介绍了问题ScriptManager.RegisterClientScriptBlock和jQuery在Internet Explorer 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用jGrowl的jQuery插件(<一个href=\"http://stanlemon.net/projects/jgrowl.html#samples\">http://stanlemon.net/projects/jgrowl.html#samples)要在页面上显示一些消息要做到这一点,我称之为ScriptManager.RegisterClientScriptBlock方法是这样的:

I want to use jGrowl plugin for jQuery (http://stanlemon.net/projects/jgrowl.html#samples) to display some messages on a page. To do this, I call the ScriptManager.RegisterClientScriptBlock method like this:

ScriptManager.RegisterClientScriptBlock(this, typeof(Page), Guid.NewGuid().ToString(),
   "$.jGrowl('" + message + "');", true);

在code在Firefox / Chrome浏览器/ Safari浏览器完美。然而,在Internet Explorer中我没有看到通知,我没有得到任何JavaScript错误。

The code works perfect in Firefox/Chrome/Safari. However in Internet Explorer I don't see the notification and I don't get any Javascript error.

我在Windows 7下工作,我的Internet Explorer 8 Beta版(版本8.0.7000.0)和我有同样的错误在兼容模式。

I work under Windows 7 and I have Internet Explorer 8 Beta (version 8.0.7000.0) and I have the same "bug" under Compatibility Mode.

我该如何解决这个问题呢?

How can I solve this problem?

推荐答案

这个问题是由于IE8预计可以进行修改的DOM之前加载所有DOM元素。我能够复制你jGrowl描述的问题。

This problem occurs because IE8 expects all the DOM elements to be loaded before modifications to the DOM can be made. I was able to duplicate the problem you described with jGrowl.

要修复它,我只是修改你的脚本,以便调用jGrowl发生一次文件已准备就绪。下面是更新code:

To fix it, I just modified your script so that the call to jGrowl happens once the document is ready. Here's the updated code:

ScriptManager.RegisterClientScriptBlock(this, typeof(Page), 
     Guid.NewGuid().ToString(),
     "$(function(){$.jGrowl('" + message + "');});", true);

这篇关于问题ScriptManager.RegisterClientScriptBlock和jQuery在Internet Explorer 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆