2013-10-01 148 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");  
}