Software Archive
Read-only legacy content

How to open a web page at launch?

Diing_Shiang_W_
Beginner
889 Views

Hi, 

Im learning to build a simple app. In this app, at launch(afteer splash screen , I want it open my website URL directly on the main screen without any click on any button. I have tried with window.open() and also included the device and In App Browser plugins but not workingwhen I emulate it on my android phone. Below is my code. please let me who what I missed. Thanks in advance.

        <script src="intelxdk.js"></script>
        <!-- phantom library, needed for XDK "legacy" container api calls -->
        <script src="cordova.js"></script>
        <!-- phantom library, needed for Cordova api calls -->
        <script src="xhr.js"></script>
        <!-- phantom library, needed for XDK "legacy" container CORS -->

        <script src="js/app.js"></script>
        <script src="js/init-app.js"></script>
        <script src="js/init-dev.js"></script>
        <!--                        
                        You may substitute jQuery for the App Framework selector library.
                        See http://app-framework-software.intel.com/documentation.php#afui/afui_jquery
                -->
        <script type="application/javascript" src="app_framework/2.1/appframework.js"></script>
        <script type="application/javascript" src="app_framework/2.1/appframework.ui.js" data-ver="1"></script>
        <!--            
            You may substitute jQuery for the App Framework selector library.
            See http://app-framework-software.intel.com/documentation.php#afui/afui_jquery
        -->
        <script type="application/javascript" src="js/jquery.min.js"></script>
        <script type="application/javascript" src="sidebar/js/jquery.event.move.js"></script>
        <script type="application/javascript" src="sidebar/js/jquery.event.swipe.js"></script>
        <script type="application/javascript" src="sidebar/js/sidebar.js"></script>
        <script type="application/javascript" src="sidebar/js/swipe.js"></script>
        <script type="application/javascript" src="js/index_user_scripts.js"></script>
        <script type="application/javascript" src="js/af_subpage.js"></script>
        <script type="text/javascript">
        var onDeviceReady=function(){                             // called when Cordova is ready
           if( window.Cordova && navigator.splashscreen ) {     // Cordova API detected
                navigator.splashscreen.hide() ;                 // hide splash screen
            }
        } ;
        document.addEventListener("deviceready", onDeviceReady, false) ;
    </script>
    </head>

    <body id="afui">

        <!-- IMPORTANT: Do not include your weinre script tag as part of your release builds! -->
        <!-- Place your remote debugging (weinre) script URL from the Test tab here, if it does not work above -->
        <!-- <script src="http://debug-software.intel.com/target/target-script-min.js#insertabiglongfunkynumberfromthexdkstesttab"></script> -->

        <div class="uwrap" id="content">
            <div class="upage panel" id="mainpage" data-header="af-header-0" data-footer="none">
                <div class="upage-outer">
                    <header class="container-group inner-element uib_w_1" data-uib="app_framework/header" data-ver="1" id="af-header-0">
                        <h1>Exhitz</h1>
                        <div class="widget-container wrapping-col single-centered"></div>
                        <div class="widget-container content-area horiz-area wrapping-col left">
                            <a class="button widget uib_w_9 d-margins icon folder" data-uib="app_framework/button" data-ver="1" id="sidemenu_button"></a>
                        </div>
                        <div class="widget-container content-area horiz-area wrapping-col right"></div>
                    </header>
                    <div class="upage-content" id="mainsub">
window.open(http://exhitz.com,"_system")
                    </div>
                    <div id="profile_page" class="upage-content hidden">

                        <div class="grid grid-pad urow uib_row_5 row-height-5" data-uib="layout/row" data-ver="0">
                            <div class="col uib_col_5 col-0_12-12" data-uib="layout/col" data-ver="0">

 

0 Kudos
4 Replies
Hamilton_Tenório_da_
Valued Contributor I
889 Views

You can use this command:

intel.xdk.device.launchExternal(yourURL);

 

 

0 Kudos
John_H_Intel2
Employee
889 Views

Why are you trying to launch an external site? I have seen users in the past try to make their 'app' simply redirect to a webiste when launched. Just a word of warning, Apple will not approve this type of app due to the fact they will say it is just a webapp and should be submitted as such.

0 Kudos
Roman_B_
Beginner
889 Views

Don't use

intel.xdk.device.launchExternal(yourURL);

Install new version of plugin InAppBrowser from cordova registry. Is far better on more customisable!

 

0 Kudos
Anusha_M_Intel1
Employee
889 Views

You need to specify it within device ready. The following code works:

 <script type="text/javascript">
        var onDeviceReady=function(){                             // called when Cordova is ready
           if( window.Cordova && navigator.splashscreen ) {     // Cordova API detected
                navigator.splashscreen.hide() ;                 // hide splash screen
            }
            var ref = window.open('http://apache.org', '_blank', 'location=yes');
        } ;
        document.addEventListener("deviceready", onDeviceReady, false) ;
    </script>

 

0 Kudos
Reply