Microsoft Edge 在尝试将克隆的内容附加到新窗口时抛出不支持此类接口"错误.这是一个例子:
Microsoft Edge is throwing 'No such interface supported' error when trying to append cloned content into new window. Here is an example:
jQuery(document).ready(function() {
jQuery('.trigger').click(function() {
var target = jQuery(this).data('print_target');
var w = window.open('', '', 'status=no, toolbar=no, menubar=no, location=no');
var print_html = '<!DOCTYPE html><head><title>' + document.getElementsByTagName('title')[0].innerHTML + '</title></head><body></body></html>';
w.document.write( print_html );
var ua = window.navigator.userAgent;
var ie = true;
//.html() required for IE browsers
if ( ua.indexOf("MSIE ") != -1) {
//console.log('MSIE - Craptastic');
jQuery(w.document.body).append( jQuery( target ).clone( true ).html() );
}
else if ( ua.indexOf("Trident/") != -1) {
//console.log('IE 11 - Trident');
jQuery(w.document.body).append( jQuery( target ).clone( true ).html() );
}
else if ( ua.indexOf("Edge/") != -1 ){
console.log('IE 12 - Edge');
//error: No such interface supported
jQuery(w.document.body).append( jQuery( target ).clone( true ).html() );
//works
//jQuery(w.document.body).append( 'hey dude, this is some text' );
//works
//jQuery(w.document.body).html( jQuery( target ).clone( true ).html() );
}
else{
//console.log('proper browser');
jQuery(w.document.body).append( jQuery( target ).clone( true ) );
ie = false;
}
});
});
这只是 Microsoft Edge 的一个问题,它适用于所有基于标准的浏览器和 IE 浏览器 7、8、9、10 和 11.类似的问题是 在此线程中提出 但未解决.
This is only an issue with Microsoft Edge, it works in all standards based browsers and IE browsers 7,8,9,10 and 11. A similar issue has been raised in this thread but not resolved.
这里有一个 jsfiddle 显示什么是什么:https://jsfiddle.net/switzerbaden/nhtywLsp/
here is a jsfiddle showing what's what: https://jsfiddle.net/switzerbaden/nhtywLsp/
先clone HTML,然后在之前添加div,之后关闭:
First clone the HTML, then add div before and close it after:
var new_target = jQuery.trim( jQuery( target ).clone( true ).html() );
jQuery( w.document.body ).append( "<div>" + new_target + "</div>" );
上一篇:考虑到3分,我该如何计算法向矢量?考虑到、我该、矢量、算法
下一篇:我怎样绘制&QUOT;软QUOT;在WPF线(presumably使用一个LinearGradientBrush)?WPF、QUOT、LinearGradientBrush、presumably