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 6591671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:27:18+00:00 2026-05-25T17:27:18+00:00

I am using a javascript code to display an ad in my page .

  • 0

I am using a javascript code to display an ad in my page . The javascript code for the corresponding ad display is as shown below :

var ad = {
    encode: function(str) {
        return escape(this._utf8_encode(str));
    },

    _utf8_encode: function(str) {
        str = str.replace(/\r\n/g, "\n");
        var utftext = "";

        for (var n = 0; n < str.length; n++) {

            var c = str.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if ((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }
        return utftext;
    }
}

var partnerId = "b7241ebe72fa74ce";
var siteId = "11738";

var targetparams = new Array();
targetparams['ad_platform'] = "ros";
var targetparams_str = "";
for (var key in targetparams) {
    if (targetparams_str != "") {
        targetparams_str += "||";
    }
    targetparams_str += ad.encode(key) + "=>" + ad.encode(targetparams[key]);
}
targetparams_str = ad.encode(targetparams_str);

var m3_u = 'http://ads.admarvel.com/fam/javascriptGetAd.php';
var m3_r = Math.floor(Math.random() * 99999999999);
document.write("<scr" + "ipt type='text/javascript' src='" + m3_u);
document.write("?partner_id=" + partnerId);
document.write('&amp;site_id=' + siteId);
document.write('&amp;target_params=' + targetparams_str);
document.write('&amp;version=1.5');
document.write('&amp;language=javascript');
document.write('&amp;format=wap');
document.write('&amp;cb=' + m3_r);
document.write("'><\/scr" + "ipt>");

The above code is inside a element in the HTML body.
Now in my page I want to include an external js library protoaculous.1.8.2.min.js and when I place this js file in the head , somehow , my ad disapperars , but as soon as I remove the external library , the ad is displayed .

The outline of my page is as below :

<head>
<script type="text/javascript" src="http://www.ectnews.com/shared/ajax/protoaculous.1.8.2.min.js"></script>
<body>
    <div>
        //Javascript code for the ad display
    </div>
</body>

Following are the links to the scenario I have created in my test server :

Non-Working html :

http://m.smartdevicemedia.com/test_external_js.htm

Working html :

http://m.smartdevicemedia.com/test_external_js_good.htm

  • 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-05-25T17:27:19+00:00Added an answer on May 25, 2026 at 5:27 pm

    I suspect that the problem is here:

    var targetparams = new Array();
    targetparams['ad_platform'] = "ros";
    var targetparams_str = "";
    for (var key in targetparams) {
        if (targetparams_str != "") {
            targetparams_str += "||";
        }
        targetparams_str += ad.encode(key) + "=>" + ad.encode(targetparams[key]);
    }
    

    The Prototype library adds a bunch of methods to the Array prototype, and your “for … in” loop will see those. There’s no reason for “targetparams” to be an Array instance, however. It should just be an object:

    var targetparams = {};
    

    In fact, from that code above there’s no reason for “targetparams” to even exist. You could simply initialize the string to the single key that you’ve actually got hard-coded there in the lines above the loop:

    var targetparams_str = ad.encode("ad_platform") + "=>" + ad.encode("ros");
    

    It also seems very odd that you’d re-encode the whole string after building up the string from encoded pieces.

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

Sidebar

Related Questions

I'm using the following JavaScript code: <script language=JavaScript1.2 type=text/javascript> function CreateBookmarkLink(title, url) { if
I am using the following JavaScript code: var a = [23, 34, 45, 33];
Is there a way to access the page HTML source code using javascript? I
this is my code for taking external page into div using ajax what i
I am using Sphinx to document parts of Javascript code on a web page.
I've written an html page that is using some javascript to hide and display
I'm trying to find URLs in some text, using javascript code. The problem is,
I am currently using a javascript code to make an entire row in my
I am validating a zip code using Javascript that is generated server-side, and injected
I'm wondering if using the following Javascript code is reliable: if (!document.cookie) { alert('Cookies

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.