Search Unity

Unity Ads Test app js-error help

Discussion in 'Unity Ads & User Acquisition' started by woosh3, Feb 15, 2021.

  1. woosh3

    woosh3

    Joined:
    Oct 29, 2020
    Posts:
    6
    Hello,
    I am using the Unity Ads Test app. I am getting the following error, and I am stuck writing a basic test. I am new to writing playable Ads. Can someone point me the right way, please. thank you in advance.
    Error:
    js-error: Uncaught SyntaxError: Invalid or unexpected token about:srcdoc 389 38 SyntaxError: Invalid or unexpected token

    Code:
    Code (JavaScript):
    1. <!DOCTYPE html>
    2. <html>
    3.     <body>
    4.         <canvas id="myCanvas" width="200" height="100" style="border:1px solid #d3d3d3;">
    5.             Your browser does not support the HTML canvas tag.</canvas>
    6.  
    7.         <script type="text/javascript" src="mraid.js"> </script>
    8.         <script>
    9.             // Wait for the SDK to become ready
    10.             if (mraid.getState() === ‘loading’) {
    11.              mraid.addEventListener(‘ready’, onSdkReady);
    12.             } else {
    13.                 onSdkReady();
    14.             }
    15.             function viewableChangeHandler(viewable) {
    16.                 // start/pause/resume gameplay, stop/play sounds
    17.                 if(viewable) {
    18.                     showMyAd();
    19.                 } else {
    20.                     // pause
    21.                 }
    22.             }
    23.  
    24.             function onSdkReady() {
    25.                 mraid.addEventListener(‘viewableChange’, viewableChangeHandler);
    26.                 // Wait for the ad to become viewable for the first time
    27.                 if (mraid.isViewable()) {
    28.                     showMyAd();
    29.                 }
    30.             }
    31.  
    32.             function showMyAd() {
    33.                 var c = document.getElementById("myCanvas");
    34.                 var ctx = c.getContext("2d");
    35.                 ctx.moveTo(0, 0);
    36.                 ctx.lineTo(200, 100);
    37.                 ctx.stroke()
    38.             }
    39.  
    40.             function gobuy() {
    41.                 // Detect platform from user agent
    42.                 var userAgent = navigator.userAgent || navigator.vendor;
    43.                 var url = ‘https://apps.apple.com/us/app/reddit/id1064216828?itsct=apps_box&itscg=30200’;
    44.                 var android = ‘https://play.google.com/store/apps/details?id=com.reddit.frontpage’;
    45.                 if (/android/i.test(userAgent)) {
    46.                     url = android;
    47.                 }
    48.                 mraid.open(url);
    49.             }
    50.             </script>
    51.        </body>
    52. </html>
    Log:
    sdk-info: Ad with placementId "incentivizedZone" is ready.

    sdk-info: Ready to show an ad!

    sdk-info: Ad with placementId "defaultVideoAndPictureZone" is ready.

    sdk-info: Ready to show an ad!

    sdk-info: Ad with placementId "defaultVideoAndPictureZone" finished with result "SKIPPED".

    js-error: Uncaught SyntaxError: Invalid or unexpected token about:srcdoc 389 38 SyntaxError: Invalid or unexpected token

    sdk-info: Ad with placementId "defaultVideoAndPictureZone" started.