Skip to content Skip to sidebar Skip to footer

Change Iframe Source From Link Href

I need to change iframe source from url. http://jsfiddle.net/YkKu3/ My HTML: this Image

Or if you are referring to the fact that you want to dynamically read the gotothis uri, you should just read out the href attribute from the gotothis element:

$("#frameimg").attr("src", $('.gotothis').attr('href')); // Here there is no problem

Solution 2:

You have the order of events mixed up. Correct code that will load the anchor URL into the iframe:

$(window).load(function() {
    $('button').click( function(event) {
        var clicked = $(this);
        window.setTimeout(function() {
            $("#frameimg").attr("src", $(".gotothis").attr("href"));
        }, 1000);
    });
});

Live test case. (With a cute cat :))


Post a Comment for "Change Iframe Source From Link Href"