Webmaster общности: Predpriemach.com | SearchEngines.bg

    Скипни рекламата

    Автор: stoqnski

    Сигурно докато сте гледали сайт примерно като deviantart.com ви се появавя (ако не сте регнат) едно „Skip this Ad“ и ви излиза на целият екран някаква снимка/сайт . Еми в този урок ще ви покажа как да си направите такова 😉

    index.php

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <script type="text/javascript" src="splashpage.js">
    
    </script>
    tova e index.php , predi tova trqbva da vi e izlqzla reklamata

    splashpage.js

    var splashpage={
    // Aktivaciq - 1 vklychena , 0 - izklychena
    splashenabled: 1,
    
    // URL do reklamata/saita koito shte se pokazva kato reklama
    splashpageurl: "http://google.bg",
    
    enablefrequency: 0,
    displayfrequency: "2 days",
    
    
    defineheader: '<div style="padding: 5px; color: white; font: bold 16px Verdana; background: black url(blockdefault.gif) center center repeat-x;"><a style="position:absolute; top: 2px; right: 5px" href="javascript:splashpage.closeit()" title="Skip to Content"><img src="skip.gif" border="0" width="114px" height="23px" /></a>Скипни рекламата...</div>',
    
    // настройки на бисквитките
    cookiename: ["splashpagecookie", "path=/"],
    
    // автоматично да махна рекламата след 15 секунди
    autohidetimer: 15,
    
    
    launch:false,
    browserdetectstr: (window.opera&&window.getSelection) || (!window.opera && window.XMLHttpRequest), //current browser detect string to limit the script to be run in (Opera9 and other "modern" browsers)
    
    output:function(){
    document.write('<div id="slashpage" style="position: absolute; z-index: 100; color: white; background-color:white">')
    document.write(this.defineheader)
    document.write('<iframe name="splashpage-iframe" src="about:blank" style="margin:0; padding:0; width:100%; height: 100%"></iframe>')
    document.write('<br /> </div>')
    this.splashpageref=document.getElementById("slashpage")
    this.splashiframeref=window.frames["splashpage-iframe"]
    this.splashiframeref.location.replace(this.splashpageurl)
    this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
    if (!/safari/i.test(navigator.userAgent))
    this.standardbody.style.overflow="hidden"
    this.splashpageref.style.left=0
    this.splashpageref.style.top=0
    this.splashpageref.style.width="100%"
    this.splashpageref.style.height="100%"
    this.moveuptimer=setInterval("window.scrollTo(0,0)", 50)
    },
    
    closeit:function(){
    clearInterval(this.moveuptimer)
    this.splashpageref.style.display="none"
    this.splashiframeref.location.replace("about:blank")
    this.standardbody.style.overflow="auto"
    },
    
    init:function(){
    if (this.enablefrequency==1){
    if (/sessiononly/i.test(this.displayfrequency)){
    if (this.getCookie(this.cookiename[0]+"_s")==null){
    this.setCookie(this.cookiename[0]+"_s", "loaded")
    this.launch=true
    }
    }
    else if (/day/i.test(this.displayfrequency)){
    if (this.getCookie(this.cookiename[0])==null || parseInt(this.getCookie(this.cookiename[0]))!=parseInt(this.displayfrequency)){ //if persistent cookie is empty or admin has changed number of days to persist from that of the stored value (meaning, reset it)
    this.setCookie(this.cookiename[0], parseInt(this.displayfrequency), parseInt(this.displayfrequency))
    this.launch=true
    }
    }
    }
    else
    this.launch=true
    if (this.launch){
    this.output()
    if (parseInt(this.autohidetimer)>0)
    setTimeout("splashpage.closeit()", parseInt(this.autohidetimer)*1000)
    }
    },
    
    getCookie:function(Name){
    var re=new RegExp(Name+"=[^;]+", "i");
    if (document.cookie.match(re))
    return document.cookie.match(re)[0].split("=")[1]
    return null
    },
    
    setCookie:function(name, value, days){
    var expireDate = new Date()
    
    if (typeof days!="undefined"){
    var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
    document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; "+splashpage.cookiename[1]
    }
    else
    document.cookie = name+"="+value+"; "+splashpage.cookiename[1]
    }
    
    }
    
    if (splashpage.browserdetectstr && splashpage.splashenabled==1)
    splashpage.init()

    Тествано и работи под ИЕ , ОПЕРА и ФФ !

    Оставете коментар