[JavaScript] Code Source Iframe

Tiller -  
multicite Messages postés 49 Statut Membre -
Hello,

je chercherais comment récupérer le code source d'une iframe via javascript ? ^^

Marchi ^^

1 réponse

  1. multicite Messages postés 49 Statut Membre 14
     
    Salut

    Essaie cette fonction

    function getDocument(target) {
    	if (target == undefined)
    		return document;
    	else if (target.contentDocument)
    		return target.contentDocument;
    	else if (target.contentWindow)
    		return target.contentWindow.document;
    	else if (target.document)
    		return target.document;
    	else
    		throw 'unable to get document object';
    }


    que tu appelles par
    getDocument(document.getElementById("id-frame"))

    si ta frame est <iframe id="id-frame"></iframe>

    (Je n'ai pas essayé, j'ai trouvé cela sur le web
    http://www.gnucitizen.org/projects/atom)
    1