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!

Like this? Share it with your network

Share

Javascript Basics for Advertisers

  • 1,219 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,219
On Slideshare
1,219
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
7
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Javascript for Advertisers
  • 2. History Lesson
    Early 1990’s
    • Netscape Navigator ( Live Script then later Javascript )
    • 3. Internet Explorer ( VbScript then later Jscript )
    1996
    - ECMAScript or ECMA-262
  • 4. Browser Wars
  • 5. Why Javascript?
    • Language of the Web
    • 6. Huge install base
    • 7. Very expressive
    • 8. Very flexible
    • 9. Universally Hated!
  • Javascript Basics
    Variables
    variAmALocalVariable = "hello";
    iAmAGlobalVariable= "hello world";
  • 10. Javascript Basics
    Functions
    function iSayHello(){
    alert("hello");
    }
  • 11. Javascript Basics
    Parameters
    function iSayHelloToYou(name){
    alert("hello "+name);
    }
  • 12. Javascript Basics
    Flow Control
    if( theWorldIsAboutToEnd ){
    alert("Panic!");
    }else{
    alert("Have a nice cup of tea and a sit down");
    }
  • 13. Javascript Basics
    Loops
    for( var counter = 0; counter < 10; counter+=1 ){
    alert("counter is at: "+counter);
    }
  • 14. Javascript Basics
    Broswer Interaction
    document.write("<imgsrc='trackingImage.gif'/>");
    Element.onclick= callFunctionHere;
  • 15. Tracking Example
    Scripts
    <script src="%h/879366/flashwrite_1_2.js"></script>
    <SCRIPT LANGUAGE="JavaScript">…
  • 16. 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();
  • 17. 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]);
    }
    }
  • 18. 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;
    }
    }
  • 19. FV now has the value:
    "moviePath=%h/1436076/&moviepath=%h/1436076/&clickTag=%25c%25u"
  • 20. 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");
    }
  • 21. 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);
    }
    }
  • 22. 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>
  • 23. Spot the Problems!
    Hint: there are 6
    //Call the function
    myFunction();
    varmyfunction = function myFunction(){
    if iWantToDoThis {
    doSomethingCrazyExciting( 'iAmAParameter )
    doAnotherCrazyExcitingThing()
    }else{
    iDontGetCalled();
    }
  • 24. Resources
    -Firefox + Firebug
    • W3C http://www.w3schools.com/jsref/
    • 25. http://jsfiddle.net/