HTML and CSS Reference
In-Depth Information
<script type='text/javascript'>
var ad728 = document.getElementById('ad728'),
function adInit () {
ad728.addEventListener('webkitTransitionEnd', nudge300, false);
function nudge300 (event) {
ad728value = window.getComputedStyle(ad728,null).getPropertyValue('color');
if (ad728value === 'rgb(255, 255, 255)') {
if(typeof window.postMessage === 'undefined'){
console.error('Your browser does not support the communication API');
//fail over to our other method
} else {
//Same Domain
console.log('Message: ' + window.postMessage)
window.postMessage('play300', ' ' );//Insert your
domain here
//Cross Domain
postMessage('play300', ' ' );
} else {
//some other color
window.addEventListener('load', adInit, false);
First, you set up the 728 unit much like you did prior, but the main difference is you use a postMessage call that
takes two parameters. The first is the string value you want to pass, and the second is the domain for the window
object (in this case, my domain, but be sure to use the domain hosting the files), which is usually the ad server.
if you don't care much about the domain origin, you can pass a literal string value of * , which is the wildcard
and allows all domain transfers.
Now, once the user hovers over the 728 unit, you post a message to anyone listening. In this case, it will be the
300 unit, as shown in Listing 11-16.
Search WWH ::

Custom Search