Click on link does not open Android web browser (Enyo 1.0)

When I click (tap) on a link in a list or a dialog, it opens the system web browser on webOS. On Android (4.0 with PhoneGap 1.4.1), it does nothing. Anyone knows why?

Thanks!

Comments

  • That's because webOS has a default handler where trying to navigate to a non-local URL opens the browser. You'll need to intercept that yourself for other platforms unless there's some tweak/plugin to PhoneGap that does that.
  • How would I do that? BTW, it works with jQueryMobile and PhoneGap.
  • onLinkClick="linkClicked" should let you perform whatever action you need to to bring up links. forwarding it to a window.open() seems to work in iOS, but not in anything else.

  • James Harris had written a utility kind to handle this stuff (see here) however it had alot of stuff specific to his app. I have gone through and refactored it to be generic and am in the middle of testing it. I will go ahead and post it up on GitHub tonight and just warn that its not fully tested yet.
  • Thanks for the pointer. I am however more thinking about links in text in Dialogs for example.
  • @ekdikeo:
    I tried
    onLinkClick: "linkClicked"
    for my main kind and I also tried
    document.addEventListener("click", this.linkClicked.bind(this), false);
    But nothing is being called.
  • edited February 2012
    { name: "description", flex: 1, kind: "HtmlContent", allowHtml: true, onLinkClick: "linkClicked"},

    linkClicked: function(inSender, inUrl, inEvent) { //this.log(inSender, inUrl, inEvent); url = inUrl.replace(/^tel:/, ""); if(url == inUrl) { this.$.AppManService.call( { target: inUrl } ); } else { this.clickedPhoneNum = url.replace("%20", ""); this.$.phonePopupMenu.openAtEvent(inEvent); this.$.phonePopupMenu.setTitle(formatPhoneNumber(url)); } },
    taken right out of gvoice
  • Thanks! I see, this is for your HtmlContent kind, not globally. I was thinking about a global solution, but I will try that.
  • edited February 2012
    So, I changed my dialog text from "no kind" to "HtmlContent" and in linkClicked(), I used WebIntent to open the browser:
        window.plugins.webintent.startActivity({ 
            action: WebIntent.ACTION_VIEW,
            url: inUrl
          }, 
          function() {}, 
          function() {
            alert('Failed to open link via Android Intent');
          }
        );
    
    A global solution (like in webOS) still would be nice to have.
  • Sorry I should have clarified that the solution I pointed you to does in fact work for what you want. There is a processClick() function that you attach to the container of your content and it will handle links and email addresses for you. It is dependent on the ChildBrowser plugin for PhoneGap.
Sign In or Register to comment.