2012-11-18 28 views

回答

13

http://peter.sh/experiments/chromium-command-line-switches/說--window位置= X,Y是你在找什麼。

更新今年以後包含一個我幾年前寫過的小shell腳本(但回答了這個問題後),它提供了一個如何使用自定義窗口大小/位置啓動chrome的例子,並且能夠創建'假'用戶數據目錄的名稱。

它可能會也可能不會繼續工作,並有一些危險的選項設置,但你明白了..不要使用這個逐字,一些標誌可能已被重命名或被完全刪除..(如襪子代理命令一樣)

#!/bin/bash -x 

FAKEUSER="${1:-fake-chrome-user}" 
CHROMEROOT=$HOME/.chromeroot/ 

mkdir -p ${CHROMEROOT} 

export PROFILE="${CHROMEROOT}/${FAKEUSER}-chromium-profile" 
export DISK_CACHEDIR="${CHROMEROOT}/${FAKEUSER}-chromium-profile-cache" 
export DISK_CACHESIZE=4096 
export MEDIA_CACHESIZE=4096 

PARANOID_OPTIONS="\ 
     --no-displaying-insecure-content \ 
     --no-referrers \ 
     --disable-zero-suggest \ 
     --disable-sync \ 
     --cipher-suite-blacklist=0x0004,0x0005,0xc011,0xc007 \ 
     --enable-sandbox-logging >/dev/null 2>&1 
     " 


/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \ 
     --remember-cert-error-decisions \ 
     --ignore-certificate-errors \ 
     --ignore-urlfetcher-cert-requests \ 
     --allow-running-insecure-content \ 
     --window-position=2400,400 \ 
     --window-size=1500,1000 \ 
     --no-pings \ 
     --user-data-dir=${PROFILE} \ 
     --disk-cache-dir=${DISK_CACHEDIR} \ 
     --disk-cache-size=${DISK_CACHESIZE} \ 
     --media-cache-size=${MEDIA_CACHESIZE} \ 
     2>&1 


#--proxy-server="socks4://localhost:30604" \ 
#--host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost" \ 
+0

可它也可用於Firefox和IE做?我在這裏發佈了一個問題:http://stackoverflow.com/questions/26626884/chrome-app-equivalent-in-firefox-ie – liorafar

+1

可悲的是,這並不總是奏效。請參閱http://stackoverflow.com/questions/14592020/google-chrome-new-window-switch-ignores-window-position-and-window-size#comment30263659_14592020 –

+1

它可以工作,@GregBray,但您需要設置'--user-data-dir'標誌。 –

3

我用這個:

google-chrome "data:text/html;charset=ISO-8859-1,<html> 
    <head></head><body><script language=\"javascript\"> 
     window.open('http://perso.f-hauri.ch/~felix/svg/dustin_w_Clock_autonom.svg', 
      'clock','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,' 
      +'resizable=1,width=600,height=600,top=100,left=120');</script>" 

谷歌鉻彈出窗口,所以這樣的:

google-chrome "data:text/html;charset=ISO-8859-1,<html><head></head><body> 
    <button onclick=\"javascript:window.open(
     'http://perso.f-hauri.ch/~felix/svg/dustin_w_Clock_autonom.svg', 
     'clock','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,' 
     +'resizable=1,width=600,height=600,top=100,left=120');\"> clock </button>" 

給出一個很好的方法來做到這一點。

注意:這項工作也與Firefox一樣。

+0

如果你通過'onfocus'替換'onclick',只需點擊''鍵,而不是在Firefox中就可以工作......可能是一個安全問題!? –

17

要建立在@ synthesizerpatel的答案上​​,--window-position將不會在它自己的工作。

你需要啓動它,因爲它是使用--user-data-dir--chrome-frame喜歡自己的新實例:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=XXXXXXXXXX --window-size=800,600 --window-position=580,240 --app="http://www.google.com/" 
or 
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --chrome-frame --window-size=800,600 --window-position=580,240 --app="http://www.google.com/" 

可惜對我來說,有它作爲一個新的實例意味着它不會在會話/ cookie的攜帶從其他實例/等信息,所以我有正常(只有在--app參數)打開它,然後在我打開做頁面的javascript:

window.moveTo(580,240); 
window.resizeTo(800,600); 

我想,如果你打開擁有的網頁由別人,你c應該打開擁有上述js的自己的網頁,然後導航到他們的網頁。

+1

選項--chrome-frame對我不起作用,但是用'--user-data-dir'我可以正常工作。謝謝 – eeezyy

+1

看起來像已被棄用 – geotheory

+0

它也可以爲Firefox和IE?我在這裏發佈了一個問題:http://stackoverflow.com/questions/26626884/chrome-app-equivalent-in-firefox-ie – liorafar

20

當你使用谷歌的Chrome,有一個較短的方式:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" 
    --profile-directory="Default" 
    --app="data:text/html,<html><body><script>window.moveTo(580,240);window.resizeTo(800,600);window.location='http://www.test.de';</script></body></html>" 

臨:

  • 自動打開的窗口中
  • 避免了彈出窗口阻止程序
  • 打開多個不同顯示器上的窗口(多顯示器設置,需要兩個或多個Chrome配置文件)

缺點:

  • 似乎只在「應用程序」模式下工作
  • 不與其他瀏覽器
+0

另一個「專業版」 - 它適用於Chrome 51以及普通的瀏覽器配置文件;另一個答案顯然不是。 –

+0

絕對是一種解決方法。 –

+1

太好了,非常感謝你!這是爲我工作的唯一解決方案。 – cronfy

1

隨着我的最新版本的Chrome測試 - 我只需要以下。每當我關閉應用程序,它都會記住我的窗口大小和位置。

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --chrome-frame --app=https://mightytext.net/web8/?exp=1 

此版本爲我工作48.0.2564.48的β-M(64位) 和版本48.0.2564.48的β-M(64位)

+0

問題是它需要先手動調整位置和大小;他們不能被納入啓動command.com – Synetech

相關問題