在Chrome浏览器中,window.open滚动条无效

3

我有一个链接,使用window.open()打开一个弹出窗口。问题是Chrome浏览器中的滚动条无法正常工作。它们在IE和Firefox中可以工作,因此我认为这与Chrome的新滚动条有关。以下是我使用的代码示例:

html:

<a href="http://google.com">Click Me</a>

jQuery:

$('a').click(function() {
    window.open("http://google.com", "", "width=300,height=300,scrollbars=1");
});

我在这里设置了一个 jsfiddle http://jsfiddle.net/88GBR/,欢迎提出任何想法。

我认为你是对的 - 在新的滚动条被修复之前,不确定有什么解决方法。但滚轮应该还能用 - 这个问题困扰我已经有一段时间了,自从升级后就一直存在。 - Craighead
我正在使用最新版本的Chrome,你的滚动条对我来说正常工作。 - Zeeba
5个回答

2

它对我来说是反过来的,即通过尝试隐藏滚动条,我不得不将overflow: hidden;添加到动态创建窗口的body标签中。 - alboforlizo

1

对我来说工作得很好,Chrome版本为32.0.1700.76 m,在Windows Vista x32上运行。

尝试发布截图,但我没有必要的声望,尝试将其作为评论而不是答案发布,但是...声望也不够:D


是的,我以为我有最新的版本,但显然不是。我更新到32.0.1700.102版本,现在它可以工作了。在以前的版本中滚动条仍然无法工作,这还是相当糟糕的。 - Nick

0

对我来说有效,我发现我的Chrome不支持scrollbars=1,所以我将其更改为scrollbars=yes

var docprint = window.open('', '', 'scrollbars=yes,resizeable=yes,width=900, height=850'); 
    docprint.document.open(); 
    docprint.document.write('<html><head><title>Print Page Setup<\/title>'); 
    docprint.document.write('<\/head><body onLoad="self.print()"><center>');          
    docprint.document.write(data); 
    docprint.document.write('<\/center><\/body><\/html>'); 
    docprint.document.close(); 
    docprint.focus(); 

0

这种方式应该可以工作,但我建议在“div”中尝试使用window.open操作,而不是在“anchor”中使用。

$("#divClick").click(function(){ 
window.open("https://www.google.com","some","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=900px,height=500px");

}

1
谢谢,我尝试了这个方法但没有成功。我更新了Chrome到32.0.1700.102版本,现在它可以正常工作了。不过还是有点奇怪的bug。我猜那些使用这个版本Chrome的人就没办法了。我不确定该如何解决这个问题。 - Nick

0
在我的情况下.. 调用3个函数然后工作正常~!!
document.open --> document.writer --> document.close 例如

var option = 'menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=yes,resizable=yes,height=600,width=800';
var win = window.open(null, null, option);
var div = domConstruct.create('div');

/// add content in div ...

win.document.open(); // must call...
win.document.write(div.innerHTML);
win.document.close(); // must cal...


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接