2011-03-29 98 views
2

可能重复:
window.open not working in IE
Javascript “window.open” code won't work in Internet Explorer 7 or 8的window.open无法在Internet Explorer工作

我有一个全球性的检测器,检测当有人点击类的<div>内部的图像Gallery如下:

$('.Gallery a').click(function(event) { 
     event.preventDefault(); 
     window.open ($(this).attr('href'),"Gallery Image","menubar=1,resizable=1,width=500,height=600"); 
    }); 

event.preventDefault()正在工作,所以当他们点击图像时什么也没有发生。但是,在Internet Explorer中不会打开窗口。任何想法为什么,或者你知道这样做的更好方法?

在Firefox/Chrome中,它完美地工作。

回答

12

You can't have spaces in the window name in IE,实际上它只在Firefox/Chrome中“起作用”:它不适合尝试使用它们。

请注意,“名称”与“标题”或“标题”不同。该名称应该是一些程序化的ID,如“galleryWindow”;这并不是一个显示给用户任何地方的消息。

相关问题