Created
September 5, 2011 09:24
-
-
Save tzi/1194546 to your computer and use it in GitHub Desktop.
A #javascript #function : Add border on image of the page, even in #iframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fonction anonyme | |
(function (){ | |
var border_image = function(win) { | |
// On essaye de récupérer le document à partir de la fenêtre | |
var doc | |
try { | |
doc = win.document; | |
} catch(e) {} | |
// Si on a pu accéder au document | |
if (doc != null) { | |
// On récupère toutes les images du document | |
var imgs = doc.getElementsByTagName('img'); | |
if (imgs != null) { | |
// Pour chaque image | |
for (var i=0; i<imgs.length; i++) { | |
// On applique une bordure rouge | |
imgs[i].style.border = "5px red solid"; | |
} | |
} | |
// Pour chaque sous fenêtres du document | |
for (var i=0; i<win.frames.length; i++) { | |
// On relance la fonction | |
border_image(win.frames[i]); | |
} | |
} | |
} | |
// On lance pour la fenêtre principale | |
border_image(window); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment