| Accueil | Publication | Flux RSS | Accès Mobile | Newsletter | Recommander | Contact |
|
|
Vous copiez ce code. Vous le personnalisez en mettant l'adresse de votre propre image (en rouge) et le lien de destination en vert.
J'ai pris la 1ère image qui me tombait sous la main, mais il peut être sympa d'en créer une avec écrit la destination.
Dans ce cas précis, l'image amène vers la déco d'Annak. en cliquant dessus.
Vous collez ensuite ce code dans l'article de la page où vous voulez voir apparaître cette image-lien
<body onload="chargement(null)"><a href='#' onclick='redirigerObjet(); return false;' id='objetLien'><img src=' http://idata.over-blog.com/0/37/17/67/articles/oeuf1.jpg id='objetImage' style='position: absolute; z-index: 10;'/></a> '
<script type='text/javascript'>
var x1 = xObjet();
var y1 = yObjet();
var x2;
var y2;
createXObjet();
createYObjet();
var direction = (y2 - y1) / (x2 - x1);
var ordonnee = y1 - direction * x1;
var xc = x1;
var yc = y1;
var vitesse = 4.5;
function xObjet() {
return Math.floor(Math.random() * (screen.width - 250));
}
function yObjet() {
return Math.floor(Math.random() * (screen.height - 250));
}
function createXObjet() {
do {
x2 = xObjet();
} while(Math.abs(x2 - x1) < 50);
}
function createYObjet() {
do {
y2 = yObjet();
} while(Math.abs(y2 - y1) < 50);
}
function redirigerObjet() {
var objet = document.getElementById('objetLien');
if(objet.display != 'none') {
objet.display = 'none';
document.location.href = 'http://decoannak.over-blog.fr'; }
}
function deplacerObjet() {
if(xc == x2 && yc == y2) {
x1 = x2;
y1 = y2;
createXObjet();
createYObjet();
direction = (y2 - y1) / (x2 - x1);
ordonnee = y1 - direction * x1;
xc = x1;
yc = y1;
}
if(x2 > x1) {
xc += vitesse;
if(xc > x2) {
xc = x2;
}
} else {
xc -= vitesse;
if(xc < x2) {
xc = x2;
}
}
yc = Math.round(ordonnee + direction * xc);
var objet = document.getElementById('objetImage');
objet.style.left = xc + 'px';
objet.style.top = yc + 'px';
}
setInterval('deplacerObjet()', 10);
</script>
Gros bisous et bon Week end :)