locked
Advertising in HTML/JavaScript win8 app

    Question

  • I have an ad supported app created in HTML/JavaScript for Windows 8. This app was created from a blank template. I added the Microsoft test code to my default.html file and everything worked just fine. I have hyperlinks in my default.html file that navigate to other html pages to serve as other sections. I thought it would be a good idea to use my ads on these other html pages but they do not show up. The test code will not display anything, and I added the error catch code so it will tell me what is wrong, but this does not show anything either. I do have my ad.js reference in my header and it works on my home page but not the subpages. I went as far as coping my entire default.html page to my other html page so they were exactly identical and still no ad is displayed. I then deleted the ad off my of home page thinking it was refreshed to many times when I navigate from the home page to the subpage and it still does not show. The only difference in the two files after that was that it had a different name. My question is, do Microsoft ads only show up on the default.html page and not on any other?


    tanner cypret

    Tuesday, July 09, 2013 12:12 AM

Answers

  • Hello,

    I tried adding ads in subpage of a blank App locally, it worked fine.

    Please make sure the subpage is a page control not pure html page.

    Putting ads in your page, you can drag the ad.js file from the Project Explorer window to the <head> section of the default.html file and the code for the AdControl will insert automatically.

    it should like this: <script src="/MSAdvertisingJS/ads/ad.js"></script>

    please note that this line must be placed in the <head> section after the include of pagecontrol's js file; otherwise, you will encounter an error when you build your project. 

    Complete pagecontrol1.html for a sample

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>pagecontrol1</title>

        <!-- WinJS references -->
        <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
        <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
        <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>

        <link href="pagecontrol1.css" rel="stylesheet" />
        <script src="pagecontrol1.js"></script>
        <script src="/MSAdvertisingJS/ads/ad.js"></script>
    </head>
    <body>
        <div class="pagecontrol1 fragment">
            <header aria-label="Header content" role="banner">
                <button class="win-backbutton" aria-label="Back" disabled type="button"></button>
                <h1 class="titlearea win-type-ellipsis">
                    <span class="pagetitle">Welcome to pagecontrol1</span>
                </h1>
            </header>
            <section aria-label="Main content" role="main">
                <div id="myAd" style="; top: 53px; left: 0px; width: 250px; height: 250px; z-index: 1"
                    data-win-control="MicrosoftNSJS.Advertising.AdControl"
                    data-win-options="{applicationId: 'd25517cb-12d4-4699-8bdc-52040c712cab', adUnitId: '10043105'}">
                </div>
            </section>
        </div>
    </body>
    </html>

    If your problem still exist. I would like to suggest you share your markup for us to tet. Thanks.

    Hope this helps, thanks.


    Yanping Wang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by tannercypret Wednesday, July 10, 2013 3:04 AM
    • Marked as answer by Some Dude 1 Wednesday, July 10, 2013 7:39 AM
    Wednesday, July 10, 2013 2:51 AM
    Moderator

All replies

  • Hello,

    I tried adding ads in subpage of a blank App locally, it worked fine.

    Please make sure the subpage is a page control not pure html page.

    Putting ads in your page, you can drag the ad.js file from the Project Explorer window to the <head> section of the default.html file and the code for the AdControl will insert automatically.

    it should like this: <script src="/MSAdvertisingJS/ads/ad.js"></script>

    please note that this line must be placed in the <head> section after the include of pagecontrol's js file; otherwise, you will encounter an error when you build your project. 

    Complete pagecontrol1.html for a sample

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>pagecontrol1</title>

        <!-- WinJS references -->
        <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
        <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
        <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>

        <link href="pagecontrol1.css" rel="stylesheet" />
        <script src="pagecontrol1.js"></script>
        <script src="/MSAdvertisingJS/ads/ad.js"></script>
    </head>
    <body>
        <div class="pagecontrol1 fragment">
            <header aria-label="Header content" role="banner">
                <button class="win-backbutton" aria-label="Back" disabled type="button"></button>
                <h1 class="titlearea win-type-ellipsis">
                    <span class="pagetitle">Welcome to pagecontrol1</span>
                </h1>
            </header>
            <section aria-label="Main content" role="main">
                <div id="myAd" style="; top: 53px; left: 0px; width: 250px; height: 250px; z-index: 1"
                    data-win-control="MicrosoftNSJS.Advertising.AdControl"
                    data-win-options="{applicationId: 'd25517cb-12d4-4699-8bdc-52040c712cab', adUnitId: '10043105'}">
                </div>
            </section>
        </div>
    </body>
    </html>

    If your problem still exist. I would like to suggest you share your markup for us to tet. Thanks.

    Hope this helps, thanks.


    Yanping Wang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by tannercypret Wednesday, July 10, 2013 3:04 AM
    • Marked as answer by Some Dude 1 Wednesday, July 10, 2013 7:39 AM
    Wednesday, July 10, 2013 2:51 AM
    Moderator
  • My subpages are pure HTML and not page control. I am guessing this is the cause of my issue? If so, then I can convert everything over to page control sometime. Thanks for the advice.

                    

    Wednesday, July 10, 2013 3:04 AM