Skip to content


Calling iCab Mobile from within Safari on the iPhone

Almost all apps on the iPhone can easily open a URL in Safari. But normally you can’t open a URL from within Safari in other apps, for example in iCab Mobile (V 1.7).

But with a “bookmarklet” (a special bookmark which is based on JavaScript code) you can do this as well. Here’s how the bookmark URL for the bookmarklet should look like:

    javascript:location.href='web'+location.href.substring(4);

Because you can’t create Bookmarks from scratch in Safari on the iPhone, you should just create a bookmark of a random page and change its URL to the above line and the title to “Open in iCab Mobile”.

If you open this bookmarklet from within the Safari bookmarks, the currently displayed web page is passed to iCab Mobile and opened there.

The bookmarklet simply changes the URL scheme from “http” to “web” and from “https” to “webs”. And because iCab Mobile supports the “web” and “webs” schemes as a replacement for “http” and “https”, the iPhone OS will pass these modified URLs to iCab Mobile.

Posted in iCab, iPhone & iPod Touch, Tips & tricks.

Tagged with , , .


43 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. David says

    Wonder if some other developers would be amenable to putting an “Open in iCab” link in their apps. I’m really thinking particularly of Twitter apps – Tweetie in particular.

  2. Alexander Alexander says

    Yes, I hope as well that other developers will do this. I’ve already written the “AppLink” class which other developers can use in their Apps (see the new blog post from today). This new AppLink class makes it very easy to call alternate browsers like iCab Mobile.

  3. Thomas says

    So, ot clarify, iCab reserves the scheme “web”? I assume other web browsers should do the same, and so if the user has only one alternative web browser on his iPhone, links to “web:” will open that one. However, if the user has more alternative browsers, either one may “win”. For that reason, I wonder if iCab _also_ does reserver a unique scheme, such as “icab:” (and “icabs:”) so that one can still identifiy iCan in particular if one needs to?

  4. Alexander Alexander says

    @Thomas
    The “web” scheme is used in my “AppLink” proposal and while it is currently used only in iCab Mobile, it should be used by all browsers which are implementing AppLink. So this “web” scheme might not necessarily address only iCab Mobile. But it is unlikely that someone uses multiple (AppLink-aware) browsers on his iPhone permanently at the same time, so in general this shouldn’t be a problem.

    iCab Mobile also supports a scheme “icabmobile”, but which is not directly accepting an URL resources specifier as “web” is doing this. The “icabmobile” scheme is currently used by my App “NewsTap” (a Usenet Reader) to open URLs in iCab and to store bookmarks from NewsTap directly in iCab Mobile. Basically the “icabmobile” scheme accepts a general property list, so you can pass any data to iCab Mobile (like Bookmarks which do have a URL and a title and maybe some other additional properties).
    But I will extend this scheme so it will also accept a plain URL resource specifier, so with the next release of iCab Mobile you would be able to address iCab Mobile with the following modified scriptlet as well:

    javascript:location.href=’icabmobile’+location.href.substring(4);

  5. Gernot Schiefer says

    Hi Alexander,
    the first bookmarklet works fine for me. (The second version not yet.)
    But I have a wish: I use 1Password on my iPhone for all my passwords etc.
    There is a bookmarklet bookmarklet from agilewebsolutions which works together with safari but not with iCab. Can you tell me if I can change the bookmarklet so that it will work with icab too? Or do I have to ask agilewebsolutions to implement that?n
    Beste Grüße, Gernot.

  6. Alexander Alexander says

    @Gernot Schiefer
    Where do I find this bookmarklet for 1Password?
    I assume this bookmarklet should also work with iCab if all Safari-specific references are exchanged by general references. But I don’t know this bookmarklet, so I don’t know what it is doing.

  7. Gernot says

    Hi Alexander,

    as far as I understand the bookmarklet of “1Password touch Pro” is:

    javascript:window.location=’onepassword://’+window.location

    But please check it on the web page http://agilewebsolutions.com/
    If you go to http://help.agile.ws/1Password_touch/pro_edition.html
    and then click on the video then it will explain the logic of this bookmarklet.

    It works fine with Safari and I would be delighted if you can manage to let it work with iCab.

    Beste Grüße, Gernot.

  8. Alexander Alexander says

    @Gernot
    The next release of iCab Mobile will also support custom URL schemes of other Apps like 1Password (this should work already, but because of a bug it didn’t). So the 1Password bookmarklet would also work in the next release of iCab Mobile. But I think this doesn’t help yet, because the 1Password app itself would only call Safari and never iCab at the moment. So there’s still some work to do in 1Password in order to use 1Password together with iCab Mobile. But this would not be very hard at all.

  9. Gernot says

    Hi Alexander,
    yes, the 1Password bookmarklet works with the new version of iCab Mobile – but 1Password only opens Safari.
    I will send them an email and ask if they can implement iCab also.

    Best wishes, Gernot.

  10. Zobi says

    Hi i already use 1password.
    Gernot say icab mobile work with icab i try but it didn t work.
    Wich version of icab can i use ?
    It the only things why i already use safari instead of icab

  11. Alexander Alexander says

    @Zobi
    Sorry, but I’m not really sure what your problem is and what you want to do.

  12. Zobi says

    Very i try to make 1password bookmarklet available for icab mobile but it didn t work…

  13. Alexander Alexander says

    @Zobi
    What exactly have you done to create the bookmarklet in iCab Mobile? The 1Password bookmarklet should also work in iCab Mobile. The only problem is that Safari for the Mac has a bug when exporting its bookmarks (Safari forgets to escape quote characters within JavaScript URLs in the exported bookmarks), which makes the bookmarklet invalid. After correcting the errors in the exported bookmarks file, it can be imported in iCab and the bookmarklet should be in iCab as well. You need to replace all occurences of the quote character ” within javascript code of the bookmarklet by “"” in the exported file.

  14. Ben says

    Hi.
    I can’t seem to change the bookmark URL in safari. It is greyed out. The title can be changed. Is bookmarklet different to bookmark? I am new to the iPhone. Am I missing something obvious? Loving the icab browser. Thanks.

  15. Alexander Alexander says

    @Ben
    Yes, Safari is a little bit strange. If you add a new Bookmark, Safari does not allow to change the URL. But if you later edit the same Bookmark (tap on the “Edit” button in the bookmarks list and then tap on the Bookmark entry), you can change the URL.

  16. Ben says

    Thanks for the tip. It works perfectly.

  17. Jacob says

    Hi!

    I realized when using the scheme web:// or icabmobile:// iCab mobile on iPhone and iPad opens the url in an existing tab, causing the previous loaded website to be “overwritten”. This especially is annoying because history isn’t saved and you can’t go back — so the website is lost forever, if you don’t remember what you’ve been visiting before :/

    …is there a setting I missed to tell iCab mobile to open incoming URL in a new tab?

  18. Alexander Alexander says

    @Jacob
    In the settings app of the device, you’ll find some additional settings for iCab Mobile. And here there’s a switch to let other Apps open URLs in new Tabs.

  19. Jacob says

    @Alexander
    Ah, great! Thanks for the support and a really great Browser :)

  20. iCab fan says

    It looks impossible to copy any text from this page using both iCab or Safari (3GS 4.0.1)? I’ve tried to copy bookmarklet code, but was unable to to it, when I hold finger over text, nothing happens. Although I have no problems with copypasting on other pages.

  21. Alexander Alexander says

    @iCab fan
    I’ve just checked this myself, but I don’t have any problems. I can select, copy and paste text just fine.

    BTW: Selecting text is usually done by double-tapping on the text/word and holding down the finger with the second tap. A simple tap-and-hold only works on more simple web pages (which might be a bug of the iOS or a feature, but it’s not the “officially documented” way for selecting text).

  22. Shiawase says

    While I can copy text from the comments I cannot from the main body of the article I had to open it in “Readability” to copy the bookmark. The “official” way just resized the screen to the element and does not select. (iOS4.1 Safari) perhaps you need to be more simple in your markup.

  23. Alexander Alexander says

    @Shiawase
    The official way to select text in a web view is to “tap, tap-and-hold” and this works fine on my devices.
    On other views which do not zoom when double-tapped, you can double-tap for selecting text as well.

  24. Oliver Bose says

    Hi Alexander,

    both JAVA-scripts doesn’t work for me.

    Greetings,

    Olli

  25. Alexander Alexander says

    @Oliver Bose
    Which two JavaScripts do you mean? There’s only one Bookmarklet in the blog post, and this should work fine.

  26. Serg says

    Огромное спасибо!!!!!
    Этого перехода из safari в iCab Mobile так не хватало.
    Спасибо !!!!!!!

  27. Serg says

    Пишу по русски, но ….. Может быть все таки и ответите.
    Недавно скачал модуль закачки видео прямо из iCab Mobile.
    Очень нужный модуль. И вот он исчез.
    Где??? Где его взять?????
    Перевел это в английский переводчиком!!?
    I write in Russian, but ….. Maybe all the same and respond.
    Recently downloaded Module upload videos directly from iCab Mobile.
    Very appropriate module. And then he disappeared.
    Where?? Where can I get it ?????

  28. Gilles Guillemin says

    Hi Alexander,

    I’ve been using iCab Mobile for several months and it is by far the best browser available iPad, hands down. And it gets better and better after each iteration so great job.
    About this safari bookmarklet, is there a way to also close the window in safari before jumping to iCab? (otherwise there’s still the pain to remove the clutter in Safari afterwards)

  29. Alexander Alexander says

    @Gilles Guillemin
    No, this is most likely not possible. First of all, a web page is only able to close windows, which the page has opened itself with JavaScript before. So you can’t close any windows (or Tabs) which were opened by the User with Javascript code (and a bookmarklet is javascript code).

  30. g says

    If you are Jailbroken you should be using Browser Changer from Cydia as this will make iCab your default browser and never default to Safari :)

  31. Adam says

    The JavaScript doesn’t work for me either, what am I doing wrong?

  32. Alexander Alexander says

    @Adam
    The code definitely works fine. Please check the bookmarklet for typos. What exactly are you doing with this bookmarklet and what exactly happens? Some more details would be nice…

  33. Alan Westwood says

    This is a great little trick – it works just fine, and thanks for posting it. All I need now is a way of uploading a tcx file into Endomondo (it almost works with iCab with a file in the download folder selected, but it fails at the last point – the selected file never finishes loading) and I can throw away my old PC :-)

    Thanks again (also for iCab mobile which is great).

    Cheers, Alan.

  34. Nuno Dionisio says

    I tried this trick and it seems to work fine, but with a small glitch, which I think it could be fixed.

    If I have no last site open (closed iCab Mobile with a blank tab only), when in Safari I click the above mentioned bookmark to open the page in iCab Mobile, it simply opens a blank tab and 2 new tabs with the link that came from Safari.

    Am I missing some setting or this doesn’t work 100%?

    Thanks in advance

  35. Alexander Alexander says

    @Nuno Dionisio
    There’s an option “App open URL in Tab” in the iCab Mobile settings within the “Settings” App from the home screen, where you can configure iCab wether other Apps which try to open a URL in iCab will open them in a new Tab (this option is ON) or if they open them just in the active Tab (this option is OFF). This way you can control if there will be a new Tab or not.

    The problem with the two tabs that open with the same page is still unsolved. Until now I had reports about this problem only from users with “Jailbroken” devices, so I suspected that this might be an issue with some “Cydia” extension or hack that was installed on these devices. This looks like iCab gets two requests form the iOS to open this URL. So the problem most likely lies outside of iCab Mobile.

  36. Nuno Dionisio says

    @Alexander: I have a newly installed 5.01 iOS version in my iPad2 (no JB) and I have this 2 tab behavior. If you try it yourself, it doesn’t happen? This is quite annoying and it looks to me that it lies inside iCab Mobile… Can you check it please? Feel free to contact me in case I can help further.

  37. Alexander Alexander says

    @Nuno Dionisio
    It doesn’t happen on my devices at all (I can check from iOS 3.1 up to 5.1). And the way this works, I can only suspect a hick-up of the system itself.

  38. Nuno Dionisio says

    @Alexander: Not even with this info?

    Just one remark that may be important for you to track this issue: these 2 tabs only open if the app is closed. If the app was opened before, you minimize it, go to Safari and use the bookmark to open in iCab Mobile, then it works properly.

    As a last try, I disabled Settings option ‘Apps open URL i.Tabs’ and now it works flawlessly, regardless of if the app is open or not, in either iPhone4 or iPad2 (both iOS 5.01).

    With this info, I suppose you have more info to where the issue may reside in iCab Mobile, no?

  39. Efluon says

    Hmm. How to copy the above string for the bookmarklet?
    All i get is a grey selection rect that instantly disappears again..

  40. Efluon says

    Works in compressed mode. Thx.

  41. Griffon says

    @Alexander and Nuno Dionision,
    I am also having same issue as Nuno…
    It happens 100% when iCab Mobile is closed. (it means not staying as minimized in background).
    Mine is new iPad (iOS 5.1.1).
    I bought it 1 week ago and of course “NO JB”
    btw,
    What does it mean “hick-up of the system itself”?

  42. Griffon says

    PS.
    If I set option “Apps open URL i.Tab” as “OFF” in iCabMobile settings, it opens only 1 tab.
    If I set this option “ON”, same web page opens in 2 tabs.

  43. Griffon says

    No answer from Alexander…
    But New Version 6.0.1 (Released on Aug. 2nd 2012) solved “Open in 2 Tab” issue on my iPad.
    Thank you.



Some HTML is OK

or, reply to this post via trackback.