Send Current Webpage to Chrome from Safari in iOS with a Bookmarklet
The recently released Chrome browser for iOS is pretty good, and even if it’s not replacing Safari as your primary web browser on an iPhone or iPad quite yet, you may still find this bookmarklet handy which lets you instantly send the currently active web page from Safari into Chrome:
- From the iOS device, launch Safari and copy the following line javascript code:
- Bookmark this webpage (or any other) by tapping the Arrow and selecting “Add Bookmark”
- Open Safari Bookmarks and tap “Edit” and then tap to edit the newly created bookmark
- Rename it to “Send to Chrome” and hit the ‘x’ alongside the URL, then tap and hold to paste in the javascript code copied above
- Test it out by opening the bookmarks bar and selecting “Send to Chrome”
javascript:location.href="googlechrome"+location.href.substring(4);
Safari switches and Google Chrome launches with a new browser tab containing the URL you activated the bookmarklet from. If you have any issues with this not working, check how the quotations are handled when editing the bookmarklet in iOS Safari. You may need to replace each ” with %22 instead, which would look like this:
javascript:location.href=%22googlechrome%22+location.href.substring(4);
Another variation is to use this javascript snippet, which apparently works better with https URLs:
javascript:location=location.href.replace(/^https?/, 'googlechrome');
Both variations worked fine in our testing, so go with what works for you. This is a great tweak for web developers and designers who need to perform browser compatibility tests on as many different browsers as possible.
Bookmarklets are a fairly popular way to add functionality to Safari that otherwise is impossible, allowing you to do things like “View Source” from Safari in iOS, adjust font sizes of web pages, and even run Firebug lite in iOS. This particular one has circled around the web recently but originates from jonabrams.com.