Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过javascript添加href-错误的MSIE错误?_Javascript_Html - Fatal编程技术网

通过javascript添加href-错误的MSIE错误?

通过javascript添加href-错误的MSIE错误?,javascript,html,Javascript,Html,像下面这样通过javascript添加href是一种不好的做法吗?在IE8中,我看到状态栏不断加载,即使页面已经更新,我怀疑是下面的代码导致了这种情况 document.getElementById('sucessMsgId').innerHTML = 'Your profile has been updated. <a href='+xProfileUri+'>View Profile</a>'; document.getElementById('sucesmsgId

像下面这样通过javascript添加href是一种不好的做法吗?在IE8中,我看到状态栏不断加载,即使页面已经更新,我怀疑是下面的代码导致了这种情况

document.getElementById('sucessMsgId').innerHTML = 'Your profile has been updated. <a href='+xProfileUri+'>View Profile</a>';
document.getElementById('sucesmsgId')。innerHTML='您的配置文件已更新';
正确的方法是什么?使用jQuery修复上述代码是否可以解决IE状态栏加载问题

更新:发现IE浏览器状态持续加载,因为它进入了jQUery代码的这一部分,并且没有完成执行。当我将加载事件附加到iframe时,并且仅在IE8中发生这种情况

for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
            matched = handlerQueue[ i ];
            event.currentTarget = matched.elem;

            for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
                handleObj = matched.matches[ j ];

                // Triggered event must either 1) be non-exclusive and have no namespace, or
                // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
                if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {

                    event.data = handleObj.data;
                    event.handleObj = handleObj;

                    ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
                            .apply( matched.elem, args );

                    if ( ret !== undefined ) {
                        event.result = ret;
                        if ( ret === false ) {
                            event.preventDefault();
                            event.stopPropagation();
                        }
                    }
                }
            }
        }
for(i=0;i
这取决于
xProfileUri
包含的内容。如果它包含一个带引号的URL,那么它应该是ok的。确保不要忘记URI字符串前后的双引号。这可以在innerHTML分配字符串中完成,也可以在将URI值分配给
xProfileUri
时完成

编辑:假设您有以下内容

var xProfileUri = 'http://google.com';
document.getElementById('successMsgId').innerHTML = 'Your profile has been updated. <a href='+xProfileUri+'>View Profile</a>';

document.getElementById('successsgid').innerHTML=
“您的个人资料已更新。”;
//注意=号后面和大于号前面的双引号

这是由于多个事件同时发生,并且用户界面同时更新了成功消息。通过向更新UI的函数调用添加setTimeout来延迟UI的更新。

没关系。在注入
元素之前,您正在设置
href
。可能是一些分析脚本目前仍在运行,我相信是MSIE错误导致了这个问题,我将检查网络选项卡,尽管找不到网络选项卡,使用了HTTPWatch,但是,当状态栏显示进度时,没有正在进行的请求,强烈认为这是由于上面的MS错误造成的,但指定的变通方法不起作用。
Your profile has been updated <a href=http://google.com>View Profile</a>
var xProfileUri = '"http://google.com"';
//note the double quotes within the single quotes
document.getElementById('successMsgId').innerHTML =
    'Your profile has been updated. <a href="'+xProfileUri+'">View Profile</a>';
//note the double quotes after the = sign and before the greater-than sign