5 Replies Latest reply on Aug 18, 2017 10:46 AM by kerrishotts

    document.write in inappbrowser

    sayakp65241608

      i want to open a blank page and write the response(html content) getting from ajax request. below is the code snippet. but it is not working.

      $.ajax(settings).done(function (response) {

       

                          var w =  cordova.InAppBrowser.open("about:blank", '_blank', 'location=no,hardwareback=no');

                          w.addEventListener('loadstop', function() {

                              w.executeScript({ code: 'document.write(' + response + ');' });

                          });

                      });

        • 1. Re: document.write in inappbrowser
          kerrishotts Adobe Employee

          Probably either your whitelist or content-security-policy meta tag. Whitelist plugin should be in your config.xml file along with proper configuration -- you can post your config.xml (sans private info) if you want us to take a look at it. Your CSP meta tag would be in your index.html file, if present. Post that as well.

          • 2. Re: document.write in inappbrowser
            sayakp65241608 Level 1

            config.xml

            ---------------

            <widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="com.nosyworld.shoppingkart" version="1.0.0">

              <name>Shoppingkart24</name>

              <description>Shoppingkart24</description>

              <author href="http://phonegap.com" email="support@phonegap.com">Nosyworld Team</author>

              <content src="index.html"/>

              <preference name="DisallowOverscroll" value="true"/>

              <preference name="Orientation" value="portrait" />

              <preference name="SplashScreenDelay" value="6000" />

              <preference name="android-minSdkVersion" value="14"/>

              <plugin name="cordova-plugin-battery-status" source="npm" spec="~1.1.1"/>

              <plugin name="cordova-plugin-camera" source="npm" spec="~2.1.1"/>

              <plugin name="cordova-plugin-media-capture" source="npm" spec="~1.2.0"/>

              <plugin name="cordova-plugin-console" source="npm" spec="~1.0.2"/>

              <plugin name="cordova-plugin-contacts" source="npm" spec="~2.0.1"/>

              <plugin name="cordova-plugin-device" source="npm" spec="~1.1.1"/>

              <plugin name="cordova-plugin-device-motion" source="npm" spec="~1.2.0"/>

              <plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2"/>

              <plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0"/>

              <plugin name="cordova-plugin-file" source="npm" spec="~4.1.1"/>

              <plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0"/>

              <plugin name="cordova-plugin-geolocation" source="npm" spec="~2.1.0"/>

              <plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.3"/>

              <plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0"/>

              <plugin name="cordova-plugin-media" source="npm" spec="~2.2.0"/>

              <plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0"/>

              <plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.1"/>

              <plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2"/>

              <plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.0"/>

              <plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1"/>

              <plugin spec="https://github.com/macdonst/SpeechRecognitionPlugin" source="git" />

              <plugin name="cordova-plugin-x-socialsharing" source="npm" />

              <plugin name="cordova-plugin-appversion" source="npm"/>

              <icon src="icon.png"/>

              <splash src="splash.png"/>

              <platform name="android">

                <!--<icon src="www/res/icon/android/drawable-ldpi-icon.png" density="ldpi"/>

                <icon src="www/res/icon/android/drawable-mdpi-icon.png" density="mdpi"/>

                <icon src="www/res/icon/android/drawable-hdpi-icon.png" density="hdpi"/>

                <icon src="www/res/icon/android/drawable-xhdpi-icon.png" density="xhdpi"/>

                <icon src="www/res/icon/android/drawable-xxhdpi-icon.png" density="xxhdpi"/>

                <icon src="www/res/icon/android/drawable-xxxhdpi-icon.png" density="xxxhdpi"/>-->

                <!--<splash src="www/res/screen/android/drawable-land-ldpi-screen.png" density="land-ldpi"/>

                <splash src="www/res/screen/android/drawable-land-mdpi-screen.png" density="land-mdpi"/>

                <splash src="www/res/screen/android/drawable-land-hdpi-screen.png" density="land-hdpi"/>

                <splash src="www/res/screen/android/drawable-land-xhdpi-screen.png" density="land-xhdpi"/>

                <splash src="www/res/screen/android/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>

                <splash src="www/res/screen/android/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>-->

               

                <splash src="res/screen/android/splash.png" density="port-hdpi"/>

                <!--<splash src="www/res/screen/android/drawable-port-xhdpi-screen.png" density="port-xhdpi"/>

                <splash src="www/res/screen/android/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>

                <splash src="www/res/screen/android/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>-->

              </platform>

              <platform name="ios">

                <icon src="www/res/icon/ios/icon.png" platform="ios" width="57" height="57"/>

                <icon src="www/res/icon/ios/icon@2x.png" platform="ios" width="114" height="114"/>

                <icon src="www/res/icon/ios/icon-40.png" platform="ios" width="40" height="40"/>

                <icon src="www/res/icon/ios/icon-40@2x.png" platform="ios" width="80" height="80"/>

                <icon src="www/res/icon/ios/icon-50.png" platform="ios" width="50" height="50"/>

                <icon src="www/res/icon/ios/icon-50@2x.png" platform="ios" width="100" height="100"/>

                <icon src="www/res/icon/ios/icon-60.png" platform="ios" width="60" height="60"/>

                <icon src="www/res/icon/ios/icon-60@2x.png" platform="ios" width="120" height="120"/>

                <icon src="www/res/icon/ios/icon-60@3x.png" platform="ios" width="180" height="180"/>

                <icon src="www/res/icon/ios/icon-72.png" platform="ios" width="72" height="72"/>

                <icon src="www/res/icon/ios/icon-72@2x.png" platform="ios" width="144" height="144"/>

                <icon src="www/res/icon/ios/icon-76.png" platform="ios" width="76" height="76"/>

                <icon src="www/res/icon/ios/icon-76@2x.png" platform="ios" width="152" height="152"/>

                <icon src="www/res/icon/ios/icon-small.png" platform="ios" width="29" height="29"/>

                <icon src="www/res/icon/ios/icon-small@2x.png" platform="ios" width="58" height="58"/>

                <icon src="www/res/icon/ios/icon-small@3x.png" platform="ios" width="87" height="87"/>

                <splash src="www/res/screen/ios/Default-568h@2x~iphone.png" platform="ios" width="640" height="1136"/>

                <splash src="www/res/screen/ios/Default-667h.png" platform="ios" width="750" height="1334"/>

                <splash src="www/res/screen/ios/Default-736h.png" platform="ios" width="1242" height="2208"/>

                <splash src="www/res/screen/ios/Default-Landscape-736h.png" platform="ios" width="2208" height="1242"/>

                <splash src="www/res/screen/ios/Default-Landscape@2x~ipad.png" platform="ios" width="2048" height="1536"/>

                <splash src="www/res/screen/ios/Default-Landscape~ipad.png" platform="ios" width="1024" height="768"/>

                <splash src="www/res/screen/ios/Default-Portrait@2x~ipad.png" platform="ios" width="1536" height="2048"/>

                <splash src="www/res/screen/ios/Default-Portrait~ipad.png" platform="ios" width="768" height="1024"/>

                <splash src="www/res/screen/ios/Default@2x~iphone.png" platform="ios" width="640" height="960"/>

                <splash src="www/res/screen/ios/Default~iphone.png" platform="ios" width="320" height="480"/>

              </platform>

              <platform name="wp8">

                <icon src="www/res/icon/wp8/ApplicationIcon.png" platform="wp8" width="99" height="99"/>

                <icon src="www/res/icon/wp8/Background.png" platform="wp8" width="159" height="159"/>

                <splash src="www/res/screen/wp8/screen-portrait.jpg" platform="wp8" width="768" height="1280"/>

              </platform>

              <platform name="windows">

                <icon src="www/res/icon/windows/Square150x150Logo.scale-100.png" platform="windows" width="150" height="150"/>

                <icon src="www/res/icon/windows/Square30x30Logo.scale-100.png" platform="windows" width="30" height="30"/>

                <icon src="www/res/icon/windows/StoreLogo.scale-100.png" platform="windows" width="50" height="50"/>

                <splash src="www/res/screen/windows/SplashScreen.scale-100.png" platform="windows" width="620" height="300"/>

                <icon src="www/res/icon/windows/StoreLogo.scale-240.png" platform="windows" width="120" height="120"/>

                <icon src="www/res/icon/windows/Square44x44Logo.scale-100.png" platform="windows" width="44" height="44"/>

                <icon src="www/res/icon/windows/Square44x44Logo.scale-240.png" platform="windows" width="106" height="106"/>

                <icon src="www/res/icon/windows/Square70x70Logo.scale-100.png" platform="windows" width="70" height="70"/>

                <icon src="www/res/icon/windows/Square71x71Logo.scale-100.png" platform="windows" width="71" height="71"/>

                <icon src="www/res/icon/windows/Square71x71Logo.scale-240.png" platform="windows" width="170" height="170"/>

                <icon src="www/res/icon/windows/Square150x150Logo.scale-240.png" platform="windows" width="360" height="360"/>

                <icon src="www/res/icon/windows/Square310x310Logo.scale-100.png" platform="windows" width="310" height="310"/>

                <icon src="www/res/icon/windows/Wide310x150Logo.scale-100.png" platform="windows" width="310" height="150"/>

                <icon src="www/res/icon/windows/Wide310x150Logo.scale-240.png" platform="windows" width="744" height="360"/>

                <splash src="www/res/screen/windows/SplashScreenPhone.scale-240.png" platform="windows" width="1152" height="1920"/>

              </platform>

              <access origin="*"/>

              <allow-intent href="http://*/*"/>

              <allow-intent href="https://*/*"/>

              <allow-intent href="tel:*"/>

              <allow-intent href="sms:*"/>

              <allow-intent href="mailto:*"/>

              <allow-intent href="geo:*"/>

              <platform name="android">

                <allow-intent href="market:*"/>

              </platform>

              <platform name="ios">

                <allow-intent href="itms:*"/>

                <allow-intent href="itms-apps:*"/>

              </platform>

            </widget>

             

            index.html

            -----------------

            <!DOCTYPE html>

            <html>

             

            <head>

                <meta charset="utf-8" />

                <meta name="format-detection" content="telephone=no" />

                <meta name="msapplication-tap-highlight" content="no" />

                <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />

                <!-- This is a wide open CSP declaration. To lock this down for production, see below. -->

                <!--<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />-->

                <!-- Good default declaration:

                * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication

                * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly

                * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:

                    * Enable inline JS: add 'unsafe-inline' to default-src

                    * Enable eval(): add 'unsafe-eval' to default-src

                * Create your own at http://cspisawesome.com

                -->

                <!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: 'unsafe-inline' https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *" /> -->

             

                <link rel="stylesheet" type="text/css" href="css/style.css" />

                <link rel="stylesheet" type="text/css" href="css/responsive.css">

                <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.5.css">

                <link rel="stylesheet" type="text/css" href="css/swiper.min.css">

                <link rel="stylesheet" type="text/css" href="css/fontawesome-stars.css">

               

                <title>Shoppingkart24</title>

            </head>

             

            <body onload="checkSession()">

               

                <div  id="home-page">

                    <div id="main">

                   

                        <div data-role="header">

                            <div class="alertContainer">

                                <span class="alertContent"></span>

                            </div>

                            <!-- LEFT SIDEBAR -->

                            <div id="slide-out-left" class="side-nav">

                               

                                <!-- Form Search --/>

                                <div class="top-left-nav">

                                    <div class="searchbar">

                                        <i class="fa fa-search"></i>

                                        <input class="search" type="text" placeholder="Search" id="speech-text">

                                        <i onclick="startDictation()" class="fa fa-microphone search-mic"></i>

             

                                       

                                    </div>

                                </div>

                                <!-- End Form Search -->

                               

                                <!-- App/Site Menu -->

                                <div id="main-menu">

                                    <ul>

                                        <li><a href="javascript:document.changepage('index.html');"><i class="fa fa-home"></i> Home</a></li>

                                        <li class="has-sub"><a href="#"><i class="fa fa-th-list"></i> Categories</a>

                                            <ul id="menu-category">

                                                <li class="has-sub"><a href="category.html?category_id=136"><i class="fa fa-cube"></i> MEN</a>

                                                    <ul class="cat-men">

                                                       

                                                    </ul>

                                                </li>

                                                <li class="has-sub"><a href="category.html?category_id=154"><i class="fa fa-cube"></i> WOMEN</a>

                                                    <ul class="cat-women">

                                                       

                                                    </ul>

                                                </li>

                                                <li class="has-sub"><a href="category.html?category_id=710"><i class="fa fa-cube"></i> HASTASHILP (CRAFTS)</a>

                                                    <ul class="cat-crafts">

                                                       

                                                    </ul>

                                                </li>

                                                <li class="has-sub"><a href="category.html?category_id=709"><i class="fa fa-cube"></i> CUSTOM YOUR CART</a>

                                                    <ul class="cat-customcart">

                                                       

                                                    </ul>

                                                </li>

                                                <li class="has-sub"><a href="category.html?category_id=220"><i class="fa fa-cube"></i> CREATIVE PARK</a>

                                                    <ul class="cat-creative">

                                                       

                                                    </ul>

                                                </li>

                                                <li class="has-sub"><a href="category.html?category_id=219"><i class="fa fa-cube"></i> BOOKS/STATIONARY & MEDIA</a>

                                                    <ul class="cat-books">

                                                       

                                                    </ul>

                                                </li>

                                                <li class="has-sub"><a href="category.html?category_id=686"><i class="fa fa-cube"></i> CAKES & FLOWERS</a>

                                                    <ul class="cat-cakes">

                                                       

                                                    </ul>

                                                </li>

                                                <li class="has-sub"><a href="category.html?category_id=217"><i class="fa fa-cube"></i> KITCHEN & HOME DECOR</a>

                                                    <ul class="cat-kitchen">

                                                       

                                                    </ul>

                                                </li>

                                                <li class="has-sub"><a href="category.html?category_id=605"><i class="fa fa-cube"></i> COOK & EAT</a>

                                                    <ul class="cat-cook">

                                                       

                                                    </ul>

                                                </li>

                                                <li class="has-sub"><a href="category.html?category_id=778"><i class="fa fa-cube"></i> STORE IN YOUR BUDGET</a>

                                                    <ul class="cat-budget">

                                                       

                                                    </ul>

                                                </li>

                                                <li class="has-sub"><a href="category.html?category_id=609"><i class="fa fa-cube"></i> MORE HERE TO SEE</a>

                                                    <ul class="cat-more">

                                                       

                                                    </ul>

                                                </li>

                                            </ul>

                                        </li>

                                       

                                        <!-- <li><a href="cart.html"><i class="fa fa-hourglass"></i> Offer Zones</a></li> -->

                                        <li><a href="javascript:document.changepage('cart.html');" data-transition="flip"><i class="fa fa-shopping-bag"></i> Shopping Cart</a></li>

                                        <li><a href="javascript:document.changepage('checkout-shipping.html');"><i class="fa fa-shopping-basket"></i> Checkout</a>

                                           

                                        </li>

                                        <li><a href="javascript:document.changepage('order-history.html');"><i class="fa fa-google-wallet"></i> My Orders</a>

                                           

                                        </li>

                                        <li><a href="javascript:document.changepage('panel-account.html');"><i class="fa fa-users"></i> My Account</a>

                                         <li>

                                            <a href="javascript:document.changepage('wish-list.html');"><i class="fa fa-heart"></i> Wishlist</a>

                                        </li>

                                       

                                    </ul>

                                </div>

                                <!-- End Site/App Menu -->

             

                            </div>

                            <!-- END LEFT SIDEBAR -->

             

                            <!-- RIGHT SIDEBAR -->

                            <div id="slide-out-right" class="side-nav">

             

                                <!-- TABS -->

                                <div class="sidebar-tabs">

                                   

                                    <!-- Tabs Menu -->

                                    <ul class="tabs">

                                        <li class="tab"><a class="active" href="#yourcart">Your Cart</a></li>

                                       

                                    </ul>

                                    <!-- End Tabs Menu -->

             

                                </div>

             

                                <!-- Right Sidebar Tabs Content -->

                                <div class="sidebar-tabs_content">

                                   

                                    <!-- Your Cart Tabs -->

                                    <div id="yourcart">

                                       

                                        <ol class="cart-item">

                                           

                                           

                                        </ol>

             

                                        <div class="cart-action">

                                           

                                           

                                        </div>

             

                                    </div>

                                    <!-- End Your Cart Tabs -->

                                   

             

                                </div>

                                <!-- End Right Sidebar Tabs Content -->

             

                            </div>

                            <!-- END RIGHT SIDEBAR -->

                        </div>

                            <!-- MAIN PAGE -->

                            <div id="page-content">

                               

                                <!-- FIXED Top Navbar -->

                                <div class="top-navbar hs-off">

                                    <div class="top-navbar-left">

                                        <a href="#" id="menu-left" data-activates="slide-out-left">

                                            <i class="fa fa-bars"></i>

                                        </a>

                                    </div>

                                    <div class="top-navbar-right">

                                        <a class="show-search" href="#"><i class="fa fa-search"></i></a>

                                        <a href="#" class="logout" ></a>

                                        <a href="#" class="dropdown-button profile-dropdown" data-activates="dropdown1">

                                           

                                        </a>

                                        <ul id="dropdown1" class="dropdown-content">

                                           

                                        </ul>

             

                                        <a href="#" id="menu-right" data-activates="slide-out-right">

                                            <span class="cart-badge">0</span>

                                            <i class="fa fa-shopping-basket"></i>

                                        </a>

                                    </div>

                                    <div class="site-title">

                                        <h1><a href="index.html">Shoppingkart24</a></h1>

                                    </div>

                                </div>

                                <!-- End FIXED Top Navbar -->

                                <!-- Header Search -->

                                <div class="top-navbar hs-on">

                                <div class="input-group">

                                    <i class="fa fa-arrow-left hide-search"></i>

                                    <input class="header-search search" type="text" placeholder="Search here..." id="speech-text">

                                    <i onclick="startDictation()" class="fa fa-microphone search-mic"></i>

                                </div>

                                </div>

                                <!-- End Header Search -->

             

                                <div data-role="page" class="ui-content">

             

                                        <!-- Start Featured Slider -->

                                        <div class="slider-container">

                                            <div class="swiper-container">

                                                <div class="swiper-wrapper">

                                                </div>

                                                <div class="swiper-pagination"></div>

                                            </div>

                                        </div>

                                        <!-- End Featured Slider -->

             

                                        <!-- CONTENT CONTAINER -->

                                        <div class="content-container home-page">

                                           

                                            <!-- Top Product Section -->

                                            <div class="page-block margin-bottom">

             

                                                <h2 class="block-title">

                                                    <span>Top Product</span><!-- <span> tag to make blue border on this text only -->

                                                    <a href="#" class="list-all">

                                                        <i class="fa fa-th-list"></i>

                                                    </a>

                                                </h2>

             

                                                <!-- Product Listing Slider -->

                                                <!--

                                                Use .top-product class to make blue border on each item

                                                -->

                                                <ol class="product-list-slider top-product">

                                                   

                                                </ol>

                                                <!-- End Product Listing Slider -->

             

                                                <!-- Use this class (.clear) to clearing float -->

                                                <div class="clear"></div>

             

                                            </div>

                                            <!-- End Top Product Section -->

             

                                            <!-- Category Section -->   

                                            <div class="page-block margin-bottom">

             

                                                <h2 class="block-title">

                                                    <span>Main Category</span><!-- <span> tag to make blue border on this text only -->

                                                    <a href="#" class="list-all">

                                                        <i class="fa fa-th-list"></i>

                                                    </a>

                                                </h2>

             

                                                <!-- Category Listing -->

                                                <ol class="category-list">

             

                                                </ol>

             

                                                <div class="clear"></div><!-- Use this class (.clear) to clearing float -->

             

                                            </div>

                                            <!-- End Category Section -->

             

                                            <!-- Product (Static) Section -->   

                                            <div class="page-block">

                                               

                                                <h2 class="block-title">

                                                    <span>Latest Products</span>

                                                    <a href="#" class="list-all">

                                                        <i class="fa fa-th-list"></i>

                                                    </a>

                                                </h2>

             

                                                <ol class="product-list">

                                                   

                                                </ol>

                                               

                                                <div class="clear"></div><!-- Use this class (.clear) to clearing float -->

             

                                            </div>

                                            <!-- End Product (Static) Section -->   

                                       

                                        </div>

                                       

                                        <!-- END CONTENT CONTAINER -->

                                        <div data-role="footer">

                                            <div class="footer">

                                           

                                                <!-- Footer main Section -->

                                                <div class="footer-main">

                                                   

                                                    <p>

                                                        <span class="block text-small">Having problem? Contact us</span>

                                                        +91-8853875353 | support@shoppingkart24.com | <!--<a href="#">Live Chat</a>-->

                                                    </p>

             

                                                   

                                                </div>

                                                <!-- End Footer main Section -->

             

                                                <!-- Copyright Section -->

                                                <div class="copyright">

                                                    <span class="block">&copy; 2017 Shoppingkart24</span>

                                                    <div class="navigation">

                                                        <a href="terms-conditions.html">Term & Condition</a>

                                                        <a href="privacy-policy.html">Privacy Policy</a>

                                                    </div>

                                                </div>

                                                <!-- End Copyright Section -->

             

                                            </div>

                                        </div>

                                        <!-- Footer Ends -->

                   

                                </div><!-- .ui-content -->

                               

                            </div><!-- #page -->

             

                    </div><!-- #Main -->

                </div><!-- #home-page -->

                   

                <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

                <script type="text/javascript" src="js/jquery.barrating.js"></script>

                <script type="text/javascript" src="js/materialize.min.js"></script>

                <script type="text/javascript" src="js/slick.min.js"></script>

                <script type="text/javascript" src="js/jquery.slicknav.js"></script>

                <script type="text/javascript" src="js/jquery.swipebox.js"></script>

                <script type="text/javascript" src="js/custom.js"></script>

                <script type="text/javascript" src="js/product.js"></script>

                <script type="text/javascript" src="js/category.js"></script>

                <script type="text/javascript" src="js/cart.js"></script>

                <script type="text/javascript" src="js/login-register.js"></script>

                <script type="text/javascript" src="js/account.js"></script>

                <script type="text/javascript" src="js/checkout.js"></script>

                <script type="text/javascript" src="js/swiper.min.js"></script>

                <script src="js/jquery-p2r-master/jquery.p2r.js"></script>

                <!-- net alerts -->

                <script>

                        function checkSession(){

                            document.addEventListener("deviceready", onDeviceReady, true);

                        }

                        function onDeviceReady(){

                            if(localStorage.getItem("session_key")=="" || localStorage.getItem("session_key")==undefined){

                                $.ajax({

                                     url: "http://shoppingkart24.com/index.php?route=feed/rest_api/session",

                                     //data: { signature: authHeader },

                                     type: "GET",

                                     beforeSend: function(xhr){xhr.setRequestHeader('X-Oc-Merchant-Id', '1010');},

                                     success: function(response) {

                                         //$.mobile.loading('hide');

                                        localStorage.setItem("session_key", response.data.session);

                                     }

                                });

                            }

                            setInterval(function () {

                                checkConnection();

                            }, 5000);   

                            var uuid = device.uuid;

                            var model = device.model;

                            //alert(uuid +"-----"+ model);

                            var version =AppVersion.version;

                            var build = AppVersion.build;

                            //alert(version+"->>>"+build);

             

                            /*getAppVersion(function(version) {

                                alert('Native App Version: ' + version);

                            });*/

                             

                       

                        }

                        function checkConnection() {

                            var networkState = navigator.connection.type;

                            var states = {};

                            states[Connection.UNKNOWN]  = 'Unknown connection';

                            states[Connection.ETHERNET] = 'Ethernet connection';

                            states[Connection.WIFI]     = 'WiFi connection';

                            states[Connection.CELL_2G]  = 'Cell 2G connection';

                            states[Connection.CELL_3G]  = 'Cell 3G connection';

                            states[Connection.CELL_4G]  = 'Cell 4G connection';

                            states[Connection.CELL]     = 'Cell generic connection';

                            states[Connection.NONE]     = 'No network connection';

                            //alert(states[networkState]);

                            if(states[networkState]==states[Connection.NONE]){

                                $('.alertContainer').css("background-color", "#ff0000");

                                $('.alertContainer').slideDown('slow').delay(3500).slideUp('slow');

                                $('.alertContent').text('No Internet Connection.');

                                return false;

                            }

                        }

             

                        function startDictation(){

                            var recognition;

                            recognition = new SpeechRecognition();

                            recognition.start();

                            recognition.onresult = function(event) {

                                if (event.results.length > 0) {

                                    //alert(event.results[0][0].transcript);

                                    document.getElementById('speech-text').value = event.results[0][0].transcript;

                                    document.showSpinner();

                                    //$.mobile.changePage( "search.html");

                                    document.changepage('search.html');

                                    document.search(event.results[0][0].transcript);

                                    document.hideSpinner();

                                }

                            }

                        }

                       

                        //search bar hide and show

                        $(".show-search").click(function(){

                            $(".top-navbar.hs-off").hide(500);

                            $(".top-navbar.hs-on").show();

                            $(".search").focus();

                            $(".search").val("");

                        });

                        $(".hide-search").click(function(){

                            $(".top-navbar.hs-off").show(300);

                            $(".top-navbar.hs-on").hide();

                            //$(".search").val("");

                        });

                       

                </script>

                <script>

                $(document).on("mobileinit", function() {

                    $.mobile.page.prototype.options.keepNative = "select,input,button";

                });

               

                </script>

                <script src="js/jquerymobilelib/jquery.mobile-1.4.5.min.js"></script>

                <script src="js/jquerymobilelib/jquery-ui.min.js"></script>

                <script type="text/javascript" src="cordova.js"></script>

                <script type="text/javascript" src="SpeechRecognition.js"></script>

              

            </body>

            </html>

            • 3. Re: document.write in inappbrowser
              kerrishotts Adobe Employee

              A few thoughts:

               

              1. For future reference, you might want to post links to a gist or pastebin or something like that when posting a large amount of code. Easier to read that way.
              2. What's the "response" from your AJAX call look like?
              3. Your CSP is commented out. You should have a working CSP that isn't wide open.
              4. Your whitelist is wide open. Not a good idea -- you should only whitelist domains that you need.

               

              Having wide open CSP & whitelists while you're building your app and testing other things is one thing, but you need to harden both of those before releasing to anyone else, especially before releasing to production.

              • 4. Re: document.write in inappbrowser
                sayakp65241608 Level 1

                Thank you for your advice. Here is the link of pastebin https://pastebin.com/jCrJLCkx of ajax response.

                • 5. Re: document.write in inappbrowser
                  kerrishotts Adobe Employee

                  With the response as provided, this is going to fail:

                   

                  w.executeScript({ code: 'document.write(' + response + ');' });

                   

                  This will be transformed into:

                   

                  document.write(

                  <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness

                  /jquery-ui.css">

                  ...

                  </script>

                  );

                   

                  Notice that you're missing quotes in this code, and so you're going to get a syntax error. If you try to add quotes (either single or double), you'll also get an error because your response includes both of those quotes.

                   

                  I would suggest just opening the original URL you're using for the AJAX call in the IAB, since it looks like you're getting regular HTML back.