Je veux charger un iframe sur un clic, c’est ce que j’ai jusqu’à présent:
$("#frame").click(function () { $('this').load("http://www.google.com/"); });
Ça ne marche pas Ceci est le code complet: JS Bin
$("#button").click(function () { $("#frame").attr("src", "http://www.example.com/"); });
HTML:
$("#frame").click(function () { this.src="http://www.google.com/"; });
Parfois, le langage JavaScript est encore plus cool et rapide que jQuery 😉
Essayez $(this).load("/file_name.html");
. Cette méthode cible un fichier local.
Vous pouvez également cibler des fichiers distants (sur un autre domaine): http://en.wikipedia.org/wiki/Same_origin_policy