分享

How to Set the Window Size and Position of a Chrome Application Shortcut

 simplelam 2014-11-18

Now that I’ve moved into the Android world, I’ve been using Google/Gmail’s “Tasks” feature to keep track of my To Do Lists.  I prefer this method to a separate stand-alone ToDo app because it’s clean & simple, and it’s one less app to manage.

I created a Chrome Application Shortcut to my Task List for easy desktop access to my To Do lists, but was dismayed to discover that the window that opened was much larger than I wanted, and it was always in an inconvenient position.  I would have to resize & move the window each time I used the Application Shortcut, because Chrome never seemed to remember the previous window settings.

I searched around for a guide on how to set the window size for application shortcuts, and to my surprise, there are no solutions out there.  Not only does the “Application Shortcut” feature lack this functionality, but Chrome itself doesn’t even have a startup switch for setting the window size.  Both seem like they’d be pretty essential features for “Application Shortcuts” to be useful, don’t you think?

I created my own method of automatically setting the window size and position using an intermediary javascript file.  It sets the window size & position, then loads your preferred target URL.  Here’s how to do it.

Step One:  Create the Application Shortcut as you normally would.

In my case, I wanted to create an Application Shortcut to Gmail’s Tasks, so I browsed to the appropriate page:

https://mail.google.com/tasks/ig

And in Chrome, choose Wrench->Tools->Create Application Shortcuts.

Step Two: Create the intermediary HTML file on your local computer.

Next, you need to create a local HTML file on your computer that resizes the window, moves it to the desired position, and then redirects to your application shortcut URL.  Here’s the file you’ll need to create:

  1. <html>  
  2. <head>  
  3. <script language="JavaScript">  
  4. window.resizeTo(300,400);  
  5. window.moveTo(1380,0);  
  6. window.location = "https://mail.google.com/tasks/ig";  
  7. </script>  
  8. </head>  
  9. <body>  
  10. <h1>If you see this, the redirect did not work properly.</h1>  
  11. </body>  
  12. </html>  

Edit the file to reflect the size & position you’d like to set.  The format is window.resizeTo(WIDTH, HEIGHT) and window.moveTo(X POSITION, Y POSITION).  If you don’t want to set an initial startup position, just remove the window.moveTo line.

You’ll also have to set the redirect target. The one listed in the above example is the one you’ll want to use for the Gmail Tasks application. To get the link for other applications, check the properties of the shortcut that you created in step 1.

Save the file somewhere where it won’t get deleted & remember the name & location.  I created a directory within “My Documents”  called “Google Tasks Shortcut” and named the file “google_tasks_launcher.html”.

Step Three:  Change the Application Shortcut to point to the intermediary file.

Now edit the Application Shortcuts you created in Step 1 to instead point to the intermediary HTML/javascript file.  Right click on the shortcut and choose “Properties.”  Then from the shortcut tab, change the Target field to point to the file you created in Step 2.

change_shortcut

You need to change the value after the “-app” switch.  In my case, I changed it as follows.

Old Value:

“C:\Documents and Settings\eddie\Local Settings\Application Data\Google\Chrome\Application\chrome.exe”  –app=https://mail.google.com/tasks/ig

New Value:

“C:\Documents and Settings\eddie\Local Settings\Application Data\Google\Chrome\Application\chrome.exe”  –app=file:///C:/Documents%20and%20Settings/eddie/My%20Documents/Google
%20Tasks%20Shortcut/google_tasks_launcher.html

I’ve bolded the parts that have changed.

You can also change the Application Shortcut icon on this screen if that strikes your fancy.

Hit “OK” and you should be set.  Your shortcut should now open at the size & position specified in the javascript portion of the HTML file.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多