我一直在研究一个与window.opener
. 我发现尝试附加对象时 IE 无法正常工作的特定问题。我在这里设置了一个演示页面。
基本上演示的作用是打开一个带有按钮的弹出窗口。正如我在上一个问题中所述,它旨在突出显示页面的某些部分。
在演示中,单击弹出窗口按钮会将两个 div 附加到window.opener
. 一个div
作为字符串添加,第二个作为对象添加。尝试附加对象时在 IE 中出现错误。这是javascript:
$(':button').click(function(){
$('#clicked').empty().show().html('Click detected!').fadeOut();
var str = '<div class="highlight" style="position:absolute;height:50px;width:50px;left:150px;top:100px;background:#fc0;zIndex:99;">str</div>';
var obj = $('<div/>', {
'class': 'highlight',
css: {
position: 'absolute',
height: '50px',
width: '50px',
left: '100px',
top: '100px',
background: '#08f',
zIndex: 99
}
}).html('obj');
try { $(window.opener.document.body).append(obj); } catch(err) { alert(err.description) };
$(window.opener.document.body).append(str);
})
所以,我正在寻求帮助来追踪 jQuery 的问题。