Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8604243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:31:30+00:00 2026-06-12T02:31:30+00:00

I have this Javacsript code that checks to see if there is a DIV

  • 0

I have this Javacsript code that checks to see if there is a DIV named “google-ad”, and if there is, it writes in a the necessary code to display the Google Ad.

This works great in browsers like Firefox, Chrome, Safari on Mac, and Android.

However, when I bundle this code with Adobe’s Phonegap Build, and deploy it to iPhones, it behaves strangely. It launches a browser window displaying just the Google Ad alone. In order to keep using my app, every time I change a page and a new Google Ad is loaded, I have to close the browser window to get back to the app.

Why is this code launching browser windows outside of my Phonegap app on iPhone?

if(document.getElementById("google-ad")
    && document.getElementById("google-ad") !== null
    && document.getElementById("google-ad") !== "undefined")
    {

    if(userStatus.status == 0)
    {
        document.getElementById("centre").style.padding = "137px 0 12px 0";
        document.getElementById("header-container").style.margin = "-138px 0 0 0";
        document.getElementById("header-container").style.height = "132px";
        document.getElementById("header-username").style.top = "52px";

        document.getElementById("google-ad").style.height = "50px";
        document.getElementById("google-ad").style.width = "320px";
        document.getElementById("google-ad").style.backgroundColor = "#f0ebff";
        document.getElementById("google-ad").style.display = "block";

        window["google_ad_client"] = 'ca-pub-0000000000000000';
        window["google_ad_slot"]  = "00000000";
        window["google_ad_width"]  = 320;
        window["google_ad_height"]  = 50;

        window.adcontainer = document.getElementById('google-ad');
        window.adhtml = '';

        function mywrite(html)
        {
            adhtml += html;
            adcontainer.innerHTML = adhtml;
        };

        document.write_ = document.write;
        document.write = mywrite;

        script = document.createElement('script');
        script.src='http://pagead2.googlesyndication.com/pagead/show_ads.js';
        script.type='text/javascript';
        document.body.appendChild(script);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:31:31+00:00Added an answer on June 12, 2026 at 2:31 am

    Problom you are facing is becuase google adsens is using iframe see in show_ads.js

    e=["<iframe"],d;for(d in a)a.hasOwnProperty(d)&&ka(e,d+"="+a[d]);e.push('style="left:0;position:absolute;top:0;"')
    

    and when that happens in phonegap(generally webview) it will open new page to show it.
    there are some ways to turn around but best way i could suggest is using google offical adsense sdk for moile :

    https://developers.google.com/mobile-ads-sdk/docs/
    

    it is native but you could easily connect it to you html app with simple plugin(i could help you with that if you want)

    the thing you are trying to do now i think cause your app to be rejected by apple so use google official sdk.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple code that speaks for itself. <script language='javascript"> function check() {}
I have this JavaScript code that creates a table, and puts in the rows
I have this javascript code below that uses jquery, it is suppoed to be
I have code that looks something like this in javascript: forloop { //async call,
I have this code: <script id=toModify > Invalid javascript that will cause errors </script>
I have this Javascript code I inherited from another developer. I am very new
i have this javascript code to which i want to add the jquery fade-in
I have this JavaScript code: for (var idx in data) { var row =
I have this javascript code <Script> function getGroupId(){ var group=document.getElementById(selectedOptions).value; var groupFirstLetter=group.substring(2); } </Script>
Hi Javascript gurus, I have this Javascript code which is working fine on Firefox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.