SlideShare a Scribd company logo
1 of 20
Javascript for
Advertisers
History Lesson
-Netscape Navigator ( Live Script then later Javascript )
-Internet Explorer ( VbScript then later Jscript )
Early 1990’s
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
var iAmALocalVariable = "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
document.write("<img src='trackingImage.gif'/>");
Element.onclick= callFunctionHere;
Broswer Interaction
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){
var swf = "%h/1436076/LW_gifting_728x90.swf";
var gif = "%h/1436076/LW_gifting_728x90.gif";
var minV = 8;
var FWH = ' width="728" height="90" ';
var url = escape("%c%u");
var fscUrl = url;
var fscUrlClickTagFound = false;
var wmode = "opaque";
var bg = "";
var dcallowscriptaccess = "never";
var openWindow = "false";
var winW = 0;
var winH = 0;
var winL = 0;
var winT = 0;
var moviePath=swf.substring(0,swf.lastIndexOf("/"));
var sm=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]);
}
}
var defaultCtVal = escape("%c%u");
var ctp=new Array();
var ctv=new Array();
ctp[0] = "clickTag";
ctv[0] = "";
Setting up Flash Variables 2/2
for(var ctIndex = 0; ctIndex < ctp.length; ctIndex++) {
var ctParam = ctp[ctIndex];
var ctVal = 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.');
var dcw = 800;
var dch = 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+",le
ft="+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 ) ) ){
var adcode='<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")&&(typeof dclkFlashWrite!="undefined")){
dclkFlashWrite(adcode);
}else{
document.write(adcode);
}
}
Tracking Example
NoScript
<noscript>
<a target="_blank" href="%c%u">
<img src="%h/1436076/LW_gifting_728x90.gif"
width="728" height="90" border="0" alt="" galleryimg="no">
</a>
</noscript>
Spot the Problems!
//Call the function
myFunction();
var myfunction = function myFunction(){
if iWantToDoThis {
doSomethingCrazyExciting( 'iAmAParameter )
doAnotherCrazyExcitingThing()
}else{
iDontGetCalled();
}
Hint: there are 6
Resources
-Firefox + Firebug
-W3C http://www.w3schools.com/jsref/
-http://jsfiddle.net/

More Related Content

What's hot

React. Redux. Real world.
React. Redux. Real world.React. Redux. Real world.
React. Redux. Real world.Rost Galkin
 
Amazing threesome, rrr... React. Redux. Real world / Ростислав Галкин (Babo)
Amazing threesome, rrr... React. Redux. Real world / Ростислав Галкин (Babo)Amazing threesome, rrr... React. Redux. Real world / Ростислав Галкин (Babo)
Amazing threesome, rrr... React. Redux. Real world / Ростислав Галкин (Babo)Ontico
 
Openstack taskflow 簡介
Openstack taskflow 簡介Openstack taskflow 簡介
Openstack taskflow 簡介kao kuo-tung
 
Tilting Google Maps and MissileLauncher
Tilting Google Maps and MissileLauncherTilting Google Maps and MissileLauncher
Tilting Google Maps and MissileLauncherTatsuhiko Miyagawa
 
Devcast node.js e mongo db o casamento perfeito
Devcast   node.js e mongo db o casamento perfeitoDevcast   node.js e mongo db o casamento perfeito
Devcast node.js e mongo db o casamento perfeitoSuissa
 
Capture and replay hardware behaviour for regression testing and bug reporting
Capture and replay hardware behaviour for regression testing and bug reportingCapture and replay hardware behaviour for regression testing and bug reporting
Capture and replay hardware behaviour for regression testing and bug reportingmartin-pitt
 
Introduction aux Macros
Introduction aux MacrosIntroduction aux Macros
Introduction aux Macrosunivalence
 
Python queue solution with asyncio and kafka
Python queue solution with asyncio and kafkaPython queue solution with asyncio and kafka
Python queue solution with asyncio and kafkaOndřej Veselý
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1Emmanuel Garcia
 
Безопасность интернет-приложений осень 2013 лекция 10
Безопасность интернет-приложений осень 2013 лекция 10Безопасность интернет-приложений осень 2013 лекция 10
Безопасность интернет-приложений осень 2013 лекция 10Technopark
 
Stegosploit - Blackhat Europe 2015
Stegosploit - Blackhat Europe 2015Stegosploit - Blackhat Europe 2015
Stegosploit - Blackhat Europe 2015Saumil Shah
 
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet WetJavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet WetMichael Girouard
 
The evolution of java script asynchronous calls
The evolution of java script asynchronous callsThe evolution of java script asynchronous calls
The evolution of java script asynchronous callsHuy Hoàng Phạm
 
Programação completa e perfeira
Programação completa e perfeiraProgramação completa e perfeira
Programação completa e perfeiraMagno Rodrigues
 
如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test名辰 洪
 
W3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptW3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptChanghwan Yi
 
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIopenFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIAtsushi Tadokoro
 

What's hot (20)

React. Redux. Real world.
React. Redux. Real world.React. Redux. Real world.
React. Redux. Real world.
 
Amazing threesome, rrr... React. Redux. Real world / Ростислав Галкин (Babo)
Amazing threesome, rrr... React. Redux. Real world / Ростислав Галкин (Babo)Amazing threesome, rrr... React. Redux. Real world / Ростислав Галкин (Babo)
Amazing threesome, rrr... React. Redux. Real world / Ростислав Галкин (Babo)
 
Openstack taskflow 簡介
Openstack taskflow 簡介Openstack taskflow 簡介
Openstack taskflow 簡介
 
Tilting Google Maps and MissileLauncher
Tilting Google Maps and MissileLauncherTilting Google Maps and MissileLauncher
Tilting Google Maps and MissileLauncher
 
Devcast node.js e mongo db o casamento perfeito
Devcast   node.js e mongo db o casamento perfeitoDevcast   node.js e mongo db o casamento perfeito
Devcast node.js e mongo db o casamento perfeito
 
Capture and replay hardware behaviour for regression testing and bug reporting
Capture and replay hardware behaviour for regression testing and bug reportingCapture and replay hardware behaviour for regression testing and bug reporting
Capture and replay hardware behaviour for regression testing and bug reporting
 
Introduction aux Macros
Introduction aux MacrosIntroduction aux Macros
Introduction aux Macros
 
Python queue solution with asyncio and kafka
Python queue solution with asyncio and kafkaPython queue solution with asyncio and kafka
Python queue solution with asyncio and kafka
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1
 
Безопасность интернет-приложений осень 2013 лекция 10
Безопасность интернет-приложений осень 2013 лекция 10Безопасность интернет-приложений осень 2013 лекция 10
Безопасность интернет-приложений осень 2013 лекция 10
 
Links of deldsim
Links of deldsimLinks of deldsim
Links of deldsim
 
Reactive x
Reactive xReactive x
Reactive x
 
Stegosploit - Blackhat Europe 2015
Stegosploit - Blackhat Europe 2015Stegosploit - Blackhat Europe 2015
Stegosploit - Blackhat Europe 2015
 
JavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet WetJavaScript from Scratch: Getting Your Feet Wet
JavaScript from Scratch: Getting Your Feet Wet
 
The evolution of java script asynchronous calls
The evolution of java script asynchronous callsThe evolution of java script asynchronous calls
The evolution of java script asynchronous calls
 
Programação completa e perfeira
Programação completa e perfeiraProgramação completa e perfeira
Programação completa e perfeira
 
ECMAScript 2015 Tips & Traps
ECMAScript 2015 Tips & TrapsECMAScript 2015 Tips & Traps
ECMAScript 2015 Tips & Traps
 
如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test
 
W3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptW3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascript
 
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIopenFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
 

Viewers also liked

Hidden treasures of Ruby
Hidden treasures of RubyHidden treasures of Ruby
Hidden treasures of RubyTom Crinson
 
Arqu hardware 02 - sockets (63170)
Arqu hardware   02 - sockets (63170)Arqu hardware   02 - sockets (63170)
Arqu hardware 02 - sockets (63170)paola
 
Arqu hardware 02 - sockets (63170)
Arqu hardware   02 - sockets (63170)Arqu hardware   02 - sockets (63170)
Arqu hardware 02 - sockets (63170)paola
 
Survey plan-updated
Survey plan-updatedSurvey plan-updated
Survey plan-updatedjryalo
 
Arqu hardware 11 - fuentes de poder (63170)
Arqu hardware   11 - fuentes de poder (63170)Arqu hardware   11 - fuentes de poder (63170)
Arqu hardware 11 - fuentes de poder (63170)paola
 
Javascript - The basics
Javascript - The basicsJavascript - The basics
Javascript - The basicsBruno Paulino
 
Javascript basics
Javascript basicsJavascript basics
Javascript basicsSolv AS
 
U97 JavaScript Webinar
U97 JavaScript WebinarU97 JavaScript Webinar
U97 JavaScript WebinarUniface
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJWORKS powered by Ordina
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery BasicsKaloyan Kosev
 
Javascript basic course
Javascript basic courseJavascript basic course
Javascript basic courseTran Khoa
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript BasicsMindfire Solutions
 
Learn Javascript Basics
Learn Javascript BasicsLearn Javascript Basics
Learn Javascript BasicsKhushiar
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testingVikas Thange
 

Viewers also liked (20)

Hidden treasures of Ruby
Hidden treasures of RubyHidden treasures of Ruby
Hidden treasures of Ruby
 
Arqu hardware 02 - sockets (63170)
Arqu hardware   02 - sockets (63170)Arqu hardware   02 - sockets (63170)
Arqu hardware 02 - sockets (63170)
 
Arqu hardware 02 - sockets (63170)
Arqu hardware   02 - sockets (63170)Arqu hardware   02 - sockets (63170)
Arqu hardware 02 - sockets (63170)
 
Survey plan-updated
Survey plan-updatedSurvey plan-updated
Survey plan-updated
 
Arqu hardware 11 - fuentes de poder (63170)
Arqu hardware   11 - fuentes de poder (63170)Arqu hardware   11 - fuentes de poder (63170)
Arqu hardware 11 - fuentes de poder (63170)
 
Project 9
Project 9Project 9
Project 9
 
Javascript - The basics
Javascript - The basicsJavascript - The basics
Javascript - The basics
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
U97 JavaScript Webinar
U97 JavaScript WebinarU97 JavaScript Webinar
U97 JavaScript Webinar
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
Java script
Java scriptJava script
Java script
 
Javascript Basics
Javascript BasicsJavascript Basics
Javascript Basics
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UX
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
 
Javascript basic course
Javascript basic courseJavascript basic course
Javascript basic course
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 
JavaScript Basics and Trends
JavaScript Basics and TrendsJavaScript Basics and Trends
JavaScript Basics and Trends
 
Learn Javascript Basics
Learn Javascript BasicsLearn Javascript Basics
Learn Javascript Basics
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testing
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 

Similar to Javascript Advertising Basics

HTML5って必要?
HTML5って必要?HTML5って必要?
HTML5って必要?GCS2013
 
HTML5 & The Open Web - at Nackademin
HTML5 & The Open Web -  at NackademinHTML5 & The Open Web -  at Nackademin
HTML5 & The Open Web - at NackademinRobert Nyman
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Chris Alfano
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkZachary Blair
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기NAVER D2
 
!DOCTYPE htmlhtml lang=enhead meta charset=utf.docx
!DOCTYPE htmlhtml lang=enhead  meta charset=utf.docx!DOCTYPE htmlhtml lang=enhead  meta charset=utf.docx
!DOCTYPE htmlhtml lang=enhead meta charset=utf.docxkatherncarlyle
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for CassandraEdward Capriolo
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"DataStax Academy
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1Bitla Software
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for youSimon Willison
 
HTML5, The Open Web, and what it means for you - MDN Hack Day, Sao Paulo
HTML5, The Open Web, and what it means for you - MDN Hack Day, Sao PauloHTML5, The Open Web, and what it means for you - MDN Hack Day, Sao Paulo
HTML5, The Open Web, and what it means for you - MDN Hack Day, Sao PauloRobert Nyman
 
Copy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with QtCopy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with Qtaccount inactive
 
Qt & Webkit
Qt & WebkitQt & Webkit
Qt & WebkitQT-day
 
When Bad Things Come In Good Packages
When Bad Things Come In Good PackagesWhen Bad Things Come In Good Packages
When Bad Things Come In Good PackagesSaumil Shah
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the mastersAra Pehlivanian
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?Ankara JUG
 
SSL Failing, Sharing, and Scheduling
SSL Failing, Sharing, and SchedulingSSL Failing, Sharing, and Scheduling
SSL Failing, Sharing, and SchedulingDavid Evans
 

Similar to Javascript Advertising Basics (20)

HTML5って必要?
HTML5って必要?HTML5って必要?
HTML5って必要?
 
HTML5 & The Open Web - at Nackademin
HTML5 & The Open Web -  at NackademinHTML5 & The Open Web -  at Nackademin
HTML5 & The Open Web - at Nackademin
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application Framework
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
!DOCTYPE htmlhtml lang=enhead meta charset=utf.docx
!DOCTYPE htmlhtml lang=enhead  meta charset=utf.docx!DOCTYPE htmlhtml lang=enhead  meta charset=utf.docx
!DOCTYPE htmlhtml lang=enhead meta charset=utf.docx
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1
 
A More Flash Like Web?
A More Flash Like Web?A More Flash Like Web?
A More Flash Like Web?
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for you
 
HTML5, The Open Web, and what it means for you - MDN Hack Day, Sao Paulo
HTML5, The Open Web, and what it means for you - MDN Hack Day, Sao PauloHTML5, The Open Web, and what it means for you - MDN Hack Day, Sao Paulo
HTML5, The Open Web, and what it means for you - MDN Hack Day, Sao Paulo
 
V8
V8V8
V8
 
Copy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with QtCopy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with Qt
 
Qt & Webkit
Qt & WebkitQt & Webkit
Qt & Webkit
 
JavaFX
JavaFXJavaFX
JavaFX
 
When Bad Things Come In Good Packages
When Bad Things Come In Good PackagesWhen Bad Things Come In Good Packages
When Bad Things Come In Good Packages
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the masters
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
 
SSL Failing, Sharing, and Scheduling
SSL Failing, Sharing, and SchedulingSSL Failing, Sharing, and Scheduling
SSL Failing, Sharing, and Scheduling
 

More from Tom Crinson

Destructuring demystified
Destructuring demystifiedDestructuring demystified
Destructuring demystifiedTom Crinson
 
A few questions on MongoDB
A few questions on MongoDBA few questions on MongoDB
A few questions on MongoDBTom Crinson
 
Higher Order Ruby
Higher Order RubyHigher Order Ruby
Higher Order RubyTom Crinson
 
Itty bittypresentation lrug
Itty bittypresentation lrugItty bittypresentation lrug
Itty bittypresentation lrugTom Crinson
 
Object Oriented Design Principles - SOLID
Object Oriented Design Principles - SOLIDObject Oriented Design Principles - SOLID
Object Oriented Design Principles - SOLIDTom Crinson
 
Test Driven Development: Why I hate it; but secretly love it.
Test Driven Development: Why I hate it; but secretly love it. Test Driven Development: Why I hate it; but secretly love it.
Test Driven Development: Why I hate it; but secretly love it. Tom Crinson
 

More from Tom Crinson (7)

Destructuring demystified
Destructuring demystifiedDestructuring demystified
Destructuring demystified
 
Crystal Agile
Crystal AgileCrystal Agile
Crystal Agile
 
A few questions on MongoDB
A few questions on MongoDBA few questions on MongoDB
A few questions on MongoDB
 
Higher Order Ruby
Higher Order RubyHigher Order Ruby
Higher Order Ruby
 
Itty bittypresentation lrug
Itty bittypresentation lrugItty bittypresentation lrug
Itty bittypresentation lrug
 
Object Oriented Design Principles - SOLID
Object Oriented Design Principles - SOLIDObject Oriented Design Principles - SOLID
Object Oriented Design Principles - SOLID
 
Test Driven Development: Why I hate it; but secretly love it.
Test Driven Development: Why I hate it; but secretly love it. Test Driven Development: Why I hate it; but secretly love it.
Test Driven Development: Why I hate it; but secretly love it.
 

Javascript Advertising Basics

  • 2. History Lesson -Netscape Navigator ( Live Script then later Javascript ) -Internet Explorer ( VbScript then later Jscript ) Early 1990’s 1996 - ECMAScript or ECMA-262
  • 4. Why Javascript? -Language of the Web -Huge install base -Very expressive -Very flexible -Universally Hated!
  • 5. Javascript Basics Variables var iAmALocalVariable = "hello"; iAmAGlobalVariable = "hello world";
  • 8. Javascript Basics Flow Control if( theWorldIsAboutToEnd ){ alert("Panic!"); }else{ alert("Have a nice cup of tea and a sit down"); }
  • 9. Javascript Basics Loops for( var counter = 0; counter < 10; counter+=1 ){ alert("counter is at: "+counter); }
  • 12. Tracking Example Function and Variable Declarations function DCFlash(id,pVM){ var swf = "%h/1436076/LW_gifting_728x90.swf"; var gif = "%h/1436076/LW_gifting_728x90.gif"; var minV = 8; var FWH = ' width="728" height="90" '; var url = escape("%c%u"); var fscUrl = url; var fscUrlClickTagFound = false; var wmode = "opaque"; var bg = ""; var dcallowscriptaccess = "never"; var openWindow = "false"; var winW = 0; var winH = 0; var winL = 0; var winT = 0; var moviePath=swf.substring(0,swf.lastIndexOf("/")); var sm=new Array();
  • 13. 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]); } }
  • 14. var defaultCtVal = escape("%c%u"); var ctp=new Array(); var ctv=new Array(); ctp[0] = "clickTag"; ctv[0] = ""; Setting up Flash Variables 2/2 for(var ctIndex = 0; ctIndex < ctp.length; ctIndex++) { var ctParam = ctp[ctIndex]; var ctVal = 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; } }
  • 15. FV now has the value: "moviePath=%h/1436076/&moviepath=%h/1436076/&clickTag=%25c%25u"
  • 16. function FSWin(){ if((openWindow=="false")&&(id=="DCF0"))alert('openWindow is wrong.'); var dcw = 800; var dch = 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+",le ft="+winL+",status=no,toolbar=no,menubar=no,location=no"); }
  • 17. ua=navigator.userAgent; if( minV <= pVM && (openWindow =="false" || (ua.indexOf("Mac") < 0 && ua.indexOf("Opera") < 0 ) ) ){ var adcode='<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")&&(typeof dclkFlashWrite!="undefined")){ dclkFlashWrite(adcode); }else{ document.write(adcode); } }
  • 18. Tracking Example NoScript <noscript> <a target="_blank" href="%c%u"> <img src="%h/1436076/LW_gifting_728x90.gif" width="728" height="90" border="0" alt="" galleryimg="no"> </a> </noscript>
  • 19. Spot the Problems! //Call the function myFunction(); var myfunction = function myFunction(){ if iWantToDoThis { doSomethingCrazyExciting( 'iAmAParameter ) doAnotherCrazyExcitingThing() }else{ iDontGetCalled(); } Hint: there are 6
  • 20. Resources -Firefox + Firebug -W3C http://www.w3schools.com/jsref/ -http://jsfiddle.net/