2013-10-01 149 views
9

我试图window.open并希望JavaScript打开新的网址一个新的浏览器,并希望新的窗口之后才能调整大小和滚动的window.open不能调整大小,滚动

我试图

window.open("someurl", '_blank','windowOpenTab', 'scrollbars=1,resizable=1,width=1000,height=580,left=0, top=0'); 

EDIT1:试图window.open(url, '_blank','windowOpenTab', 'scrollbars=1,resizable=1,width=1000,height=580,left=0,top=0'); 仍然没有运气

阅读有关window.open从http://www.javascript-coder.com/window-popup/javascript-window-open.phtml但没有运气:(

+1

你不能在这最后的字符串 – Sergio

+0

@Sergio空间 - 更新还是一样:( – Varun

回答

16

根据MDN您只能在该功能中有3个参数。

window.open(strUrl, strWindowName[, strWindowFeatures]); 

演示here - 我DROP掉了'_blank'并提出用小窗口演示只是为了让滚动条showup。

所以,你可以使用:

window.open("someurl", 'windowOpenTab', 'scrollbars=1,resizable=1,width=1000,height=580,left=0,top=0'); 
+0

我想确保它打开新窗口永远不会有,它会打开一个新标签 – Varun

+0

@Varun,我不确定这是跨浏览器compat。请点击这里http://stackoverflow.com/questions/4907843/open-url -in-new-tab-using-javascript – Sergio

+1

观察你如何拼写可调整大小,通过拼错可调整大小,我被抓出一个头撞击10分钟。 – Bob

0

变化

window.open("someurl", '_blank','windowOpenTab', 'scrollbars=1,resizable=1,width=1000,height=580,left=0, top=0'); 

window.open("someurl", 'windowOpenTab', 'scrollbars=1,resizable=1,width=1000,height=580,left=0, top=0'); 

只需卸下_blankFIDDLE

-1

尝试this

popupWin = window.open('http://webdesign.about.com/', 
'open_window','menubar, toolbar, location, directories, status, scrollbars, resizable, 
dependent, width=640, height=480, left=0, top=0') 
0

试试这个

function openPopupWindow(){ 
window.open("http://example.com","popup","width=668,height=548,scrollbars=yes, resizable=yes");  
}