• Switch Language


  • Embed to Titanium App

    Add a Script Tag

    All you need to do to integrate Linkify into your application is to simply add the script tag below in the HTML header of a web page.

    <script type="text/javascript"
      src="http://www-static.linkify.mobi/api/linkify.js?key=YOUR_API_KEY">
    </script>
    

    Example of a WebView Application

    We will show an example of how to integrate Linkify into your Titanium WebView application. We will inject the JavaScript URL to a web page (we will use Yahoo News! as an example).

    Creating an Application

    To make a WebView application, choose Default Project when making the Titanium Project.

    Application File

    Here’s an example of the app.js file. First, create a window instance. Next, create a webView instance containing the URL you want to show (e.g., Yahoo! News). Then, add the event listener to the webView so when it is loaded, the JavaScript URL will be added to the HTML header. Finally, add the webView instance into the window. The open method will open the web page! Notice that in the example below, we have loaded Linkify right after the application loaded. You may edit it to start Linkify by pressing a button or any kind of actions. We recommend copy & pasting the addEventListener method from the Linkify page since there exists an environment variable, YOUR_API_KEY inside the code below.

    var window = Titanium.UI.createWindow();
    var webView = Titanium.UI.createWebView({url:"http://news.yahoo.com"});
    
    webView.addEventListener('load', function() {
      webView.evalJS(
        "(function(){if(!window.linkified){var d=document,s=d.createElement('script');s.type='text/javascript';s.src='http://www-static.linkify.mobi/api/linkify.js?key=YOUR_API_KEY';d.getElementsByTagName('head')[0].appendChild(s);window.linkified=true;}})()"
          );
    });
    
    window.add(webView);
    window.open();
    

    Downloads

    Here is the code of the Titanium application that we have just introduced.

    Read the Docs v: latest
    Versions
    latest
    Downloads
    PDF
    HTML
    Epub
    On Read the Docs
    Project Home
    Builds

    Free document hosting provided by Read the Docs.