Archive

Posts Tagged ‘document write’

A Simple Javascript Snippet

June 19th, 2009 Comments off

Ok, so I am not well versed with javascript and do everything with php. But this one calls for a bit of js manipulation.

For someone who knows JS this should be a five minute job.

So, we are using openx for ad management. The problem is that placing the openx javacode all over the page is simply too annoying.

so we had created a single php function called disp_ads where it would be fed the ad_zone and another variable and then it would display the ad.

this is one it looks like:

function ad_disp_raw ($ad_zone, $ad_n) {
?>
<script type=’text/javascript’><!–//<![CDATA[
var m3_u = (location.protocol=='https:'?'/cp/adserver/www/delivery/ajs.php':'/cp/adserver/www/delivery/ajs.php');
var m3_r = Math.floor(Math.random()*99999999999);
if (!document.MAX_used) document.MAX_used = ',';
document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
document.write ("?zoneid=<?=$ad_zone; ?>");
document.write ('&cb=' + m3_r);
if (document.MAX_used != ',') document.write ("&exclude=" + document.MAX_used);
document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : ''));
document.write ("&loc=" + escape(window.location));
if (document.referrer) document.write ("&referer=" + escape(document.referrer));
if (document.context) document.write ("&context=" + escape(document.context));
if (document.mmm_fo) document.write ("&mmm_fo=1");
document.write ("'></scr"+"ipt>");
//]]>–></script><noscript><a href=’/cp/adserver/www/delivery/ck.php?n=<?=$ad_n; ?>&cb=INSERT_RANDOM_NUMBER_HERE’ target=’_blank’><img src=’/cp/adserver/www/delivery/avw.php?zoneid=<?=$ad_zone; ?>&cb=INSERT_RANDOM_NUMBER_HERE&n=<?=$ad_n; ?>’ border=’0′ alt=” /></a></noscript>
<?
}

// function ad_disp is a generic add display module from phpads
function ad_disp ($ad_zone, $ad_n) {
?>
<fieldset class=ads>
<legend>ADVERTISEMENT</legend>
<? ad_disp_raw ($ad_zone, $ad_n); ?>
</fieldset><?

}

———
So as you can see, sometimes we call the ad_disp function which displays a little fieldset around the ad or we can call the ad_disp_raw function directly if we don’t want the fieldset around the ad.

—-> the job:
we need the same methodology done but ALL is java. So, no php function but a java function PLUS the call.

So, really all one needs to do is write two js functions where one calls the other (see above php functions) and their call syntax – where all we do is call the function with the two variables.

right now the function calls look like this:

<? ad_disp{12, 1233s32); ?>
so we want a call that is as simple as this!

—> this needs to be done rightaway. so if you can’t do this in less than an hour don’t bid please.

Javascript Cookie Read + Write

April 4th, 2009 Comments off

Looking for someone to knock out a QUICK javascript:

Each page on a domain will call an external javascript. The primary page where a cookie is set is via a subscription/autoresponder form. The javascript cookie is created using an ON Submit and displayed elsewhere where a document.write is used.

autoresponder.js will be the main script called from every page.

It does all the heavy-lifting: creates a cookie, stores a cookie, defines an array so that document.write displays one of several variables for the cookie (ALL CAPS, First Letter Cap, All Lower Case) when the script is called. It allows the site owner to specify the field that will be read and made into a cookie AND the name of the cookie.

The autoresponder.js should have something like:

– Only change the following information in this code:–

VarName=FieldwithFirstName (change to the name of the input form field where a person enters their name)
VarCookie=CustomCookie (change to whatever name you want for the stored cookie)

– End of Custom area –

It should also define the array options: 1, All Caps 2, First Letter Cap 3, All Lower Case

When the document.write is used, case is defined by the array number above.

Pretty easy I think.

Here’s a link to someone elses version of it. Look at the page and the follow-up page.

http://www.dennissevert.com/warriors/wso.html

Let me know.

Bear