Skip to content

Instantly share code, notes, and snippets.

@tzi
Created September 5, 2011 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzi/1194546 to your computer and use it in GitHub Desktop.
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
// 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