用于显示图像不在IE中工作的PopUp

时间:2017-11-14 05:54:48

标签: javascript

我使用以下代码在新窗口中显示图像..它在Chrome中工作正常但在IE中没有... 这是我的代码..

function enlargeimg(url) {
  var newWindow = window.open("", "", "width=600,height=750");
  newWindow.document.writeln("<html>");
  newWindow.document.writeln("<body>");
  newWindow.document.writeln("<img src='" + url +"' alt='Click to close' id='bigImage'/>");
  newWindow.document.writeln("</body></html>");
  newWindow.document.close();
}

这是如何在IE popoup中显示的图像: -

enter image description here

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

IE不喜欢窗口名称中的空格或空名

试试这个,

var newWindow = window.open("", "win_with_image", "width=600,height=750");

替代解决方案:

如果图像是您必须在弹出窗口中显示的内容, 你可以试试像ref

这样的东西
function openRequestedPopup() {
   var windowObjectReference = window.open(
       "http://www.domainname.ext/path/ImageFile.png",
       "DescriptiveWindowName",
       "resizable,scrollbars,status"
   );
}
相关问题