Archivio della categoria: Programmazione

Get Root – Find iframe parent location

This function is useful to determinate information about the page who host an iframe from the iframe.

function get_root(obj, current_ref) {
if(obj.parent.location.href != current_ref) {
return get_root(obj.parent, obj.location.href);
}
else {
return obj.location.href;
}
}

Usage:

get_root(window, window.location.href)

Credits to: 3xlstudio

http://snipplr.com/view/60285/ifram-get-parent/

 

 

 

Cookie in wordpress

Impossibile utilizzarli in maniera tradizionale, si possono usare nei temi attraverso il file function es:

function setLang(){

            if ($_GET['lang'] == "it") {
                $lang = 'it';
            } elseif ($_GET['lang'] == "en") {
                $lang = 'en';
            } elseif (isset($_COOKIE["lang"])) {
                $lang = $_COOKIE["lang"];
            } else {
            $lang = 'it';
            }
            setcookie('lang', $lang, time()+2592000 , "/"); //setta il cookie della durata di un mese

            return $lang;
}

add_action('init', 'setLang');

Smart3D jQuery plugin

A nice jQuery Plugin that uses several images to create the illusion of a 3D scenario using the parallax effect.

Example of use:

$ ( function () {
$ ( ‘# Mindscape’ ). Smart3D (850);
});

#Mindscape {
width : 750px ;
height : 174px ;
}
Source

http://4coder.info/smart3d-jquery-plugin/

Demo

http://4coder.info/demo/jquery-smart3D/