Last week I talked about switching a Google Drive document from /edit to /preview and back. The process is cumbersome, requiring you to edit the address of the document.

To help with switching, I wrote a little Javascript code that will switch between the modes when clicked.

Don’t fear the bookmarklet

A bookmarklet is a piece of Javascript code that you can launch from your bookmarks bar. I’ve written a bookmarklet that will swap /edit for /preview or vice versa.

To use the bookmarklet, you’ll need to turn on the Bookmarks bar in your browser. Look under the view menu, or through your appearance settings.

Once you have the bookmark bar showing, drag the following link to the bar (don’t just click on it, click and hold so you can drag it to the bar).


The bookmarklet right now is simply a link to this website. WordPress won’t let me put the Javascript link in the post for safety reasons, so we have to edit the bookmarklet.

Copy the following code (start with the j and including everything up to the final ;):


Now, right-click on the SwitchMode bookmarklet in the bookmarks bar and select edit. Replace the current URL with the above code that you copied.

Testing it out

Now, open a Google document, for example, here is a Google Slides document you can use. Once the document is loaded in the browser, click the SwitchMode bookmarklet. The view of the document will switch between /edit and /preview every time you click the bookmarklet.


There is no error checking in the script. I don’t see how it could mess anything up, but don’t go clicking the bookmarklet on non-Google documents sites.

Be sure to subscribe to my YouTube channel and join your fellow educators on the Eduk8me email list!