Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Javascript Basics for Advertisers

on

  • 1,144 views

 

Statistics

Views

Total Views
1,144
Views on SlideShare
1,144
Embed Views
0

Actions

Likes
0
Downloads
7
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Javascript Basics for Advertisers Javascript Basics for Advertisers Presentation Transcript

    • Javascript for Advertisers
    • History Lesson
      Early 1990’s
      • Netscape Navigator ( Live Script then later Javascript )
      • Internet Explorer ( VbScript then later Jscript )
      1996
      - ECMAScript or ECMA-262
    • Browser Wars
    • Why Javascript?
      • Language of the Web
      • Huge install base
      • Very expressive
      • Very flexible
      • Universally Hated!
    • Javascript Basics
      Variables
      variAmALocalVariable = "hello";
      iAmAGlobalVariable= "hello world";
    • Javascript Basics
      Functions
      function iSayHello(){
      alert("hello");
      }
    • Javascript Basics
      Parameters
      function iSayHelloToYou(name){
      alert("hello "+name);
      }
    • Javascript Basics
      Flow Control
      if( theWorldIsAboutToEnd ){
      alert("Panic!");
      }else{
      alert("Have a nice cup of tea and a sit down");
      }
    • Javascript Basics
      Loops
      for( var counter = 0; counter < 10; counter+=1 ){
      alert("counter is at: "+counter);
      }
    • Javascript Basics
      Broswer Interaction
      document.write("<imgsrc='trackingImage.gif'/>");
      Element.onclick= callFunctionHere;
    • Tracking Example
      Scripts
      <script src="%h/879366/flashwrite_1_2.js"></script>
      <SCRIPT LANGUAGE="JavaScript">…
    • Tracking Example
      Function and Variable Declarations
      function DCFlash(id,pVM){
      varswf = "%h/1436076/LW_gifting_728x90.swf";
      var gif = "%h/1436076/LW_gifting_728x90.gif";
      varminV = 8;
      var FWH = ' width="728" height="90" ';
      varurl = escape("%c%u");
      varfscUrl = url;
      varfscUrlClickTagFound = false;
      varwmode = "opaque";
      varbg = "";
      vardcallowscriptaccess = "never";
      varopenWindow = "false";
      varwinW = 0;
      varwinH = 0;
      varwinL = 0;
      varwinT = 0;
      varmoviePath=swf.substring(0,swf.lastIndexOf("/"));
      varsm=new Array();
    • Tracking Example
      Setting up Flash Variables 1/2
      var fv='"moviePath='+moviePath+'/'+'&moviepath='+moviePath+'/';
      //This bit is essentially ignored:
      for(i=1;i<sm.length;i++){
      if(sm[i]!=""){
      fv+="&submovie"+i+"="+escape(sm[i]);
      }
      }
    • Setting up Flash Variables 2/2
      vardefaultCtVal = escape("%c%u");
      varctp=new Array();
      varctv=new Array();
      ctp[0] = "clickTag";
      ctv[0] = "";
      for(varctIndex = 0; ctIndex < ctp.length; ctIndex++) {
      varctParam = ctp[ctIndex];
      varctVal = ctv[ctIndex];
      if(ctVal != null && typeof(ctVal) == 'string') {
      if(ctVal == "") {
      ctVal = defaultCtVal;
      }
      else {
      ctVal = escape("%c" + ctVal);
      }
      if(ctParam.toLowerCase() == "clicktag") {
      fscUrl = ctVal;
      fscUrlClickTagFound = true;
      }
      else if(!fscUrlClickTagFound) {
      fscUrl = ctVal;
      }
      fv += "&" + ctParam + "=" + ctVal;
      }
      }
    • FV now has the value:
      "moviePath=%h/1436076/&moviepath=%h/1436076/&clickTag=%25c%25u"
    • function FSWin(){
      if((openWindow=="false")&&(id=="DCF0"))alert('openWindow is wrong.');
      vardcw = 800;
      vardch = 600;
      // IE
      if(!window.innerWidth)
      {
      // strict mode
      if(!(document.documentElement.clientWidth == 0))
      {
      dcw = document.documentElement.clientWidth;
      dch = document.documentElement.clientHeight;
      } else if(document.body) // quirks mode
      {
      dcw = document.body.clientWidth;
      dch = document.body.clientHeight;
      }
      } else // w3c
      {
      dcw = window.innerWidth;
      dch = window.innerHeight;
      }
      if(openWindow=="center"){
      winL=Math.floor((dcw-winW)/2);winT=Math.floor((dch-winH)/2);
      }
      window.open(unescape(fscUrl),id,"width="+winW+",height="+winH+",top="+winT+",left="+winL+",status=no,toolbar=no,menubar=no,location=no");
      }
    • ua=navigator.userAgent;
      if( minV <= pVM && (openWindow =="false" || (ua.indexOf("Mac") < 0 && ua.indexOf("Opera") < 0 ) ) ){
      varadcode='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="'+id+'"'+FWH+'>'+
      '<param name="movie" value="'+swf+'">
      <param name="flashvars" value='+fv+'>
      <param name="quality" value="high">
      <param name="wmode" value="'+wmode+'">'+
      '<param name="base" value="'+swf.substring(0,swf.lastIndexOf("/"))+'">
      <PARAM NAME="AllowScriptAccess" VALUE="'+dcallowscriptaccess+'">'+bgo+
      '<embed src="'+swf+'" flashvars='+fv+bge+FWH+' type="application/x-shockwave-flash" quality="high" swliveconnect="true" wmode="'+wmode+'" name="'+id+'" base="'+
      swf.substring(0,swf.lastIndexOf("/"))+'" AllowScriptAccess="'+dcallowscriptaccess+'"></embed></object>';
      if(('%eenv!'!="j")&&(typeofdclkFlashWrite!="undefined")){
      dclkFlashWrite(adcode);
      }else{
      document.write(adcode);
      }
      }
    • Tracking Example
      NoScript
      <noscript>
      <a target="_blank" href="%c%u">
      <imgsrc="%h/1436076/LW_gifting_728x90.gif" width="728" height="90" border="0" alt="" galleryimg="no">
      </a>
      </noscript>
    • Spot the Problems!
      Hint: there are 6
      //Call the function
      myFunction();
      varmyfunction = function myFunction(){
      if iWantToDoThis {
      doSomethingCrazyExciting( 'iAmAParameter )
      doAnotherCrazyExcitingThing()
      }else{
      iDontGetCalled();
      }
    • Resources
      -Firefox + Firebug
      • W3C http://www.w3schools.com/jsref/
      • http://jsfiddle.net/