0

I am using an iFrame to load http://www.amazon.co.uk when i press Amazon UK button and it is loading as well and i browse into sub pages of amazon.co.uk. Now what i want is to get href attribute of tags when i hover on tags or links in this iFrame. Is it possible with Javascript or jQuery Please tell me how?

--This is What i am doing

<div id="amazon_buttons">
    <table border="0">
        <tr>
            <td><a href="../../users/product" target="_top"><input id="cmdback" name="cmdback" type="button" value="Back To IEC" /></a></td>
        </tr>
        <tr>
            <td><input id="cmdanzuk" name="cmdanzuk" type="button" value="Amazon UK" onclick="open_amazon_page('uk')" /> </td>
        </tr>
        <tr>
            <td><input id="cmdanzde" name="cmdanzde" type="button" value="Amazon DE" onclick="open_amazon_page('de')" /> </td>
        </tr>
        <tr>
            <td><input id="cmdanzfr" name="cmdanzfr" type="button" value="Amazon FR" onclick="open_amazon_page('fr')" /> </td>
        </tr>
        <tr>
            <td><input id="cmdanzes" name="cmdanzes" type="button" value="Amazon ES" onclick="open_amazon_page('es')" /> </td>
        </tr>
    </table>
</div>

<iframe id="azn_iframe" name="azn_iframe" src="" style="clear: both; width: 100%; height:800px;"></iframe>

    $("#azn_iframe").contents().find("a").hover(
    function () {
        alert($(this).attr("href"));
    });

    function open_amazon_page($platform)
    {
        if($platform == 'uk')
            azn_iframe.location.href = "http://www.amazon.co.uk";
        else if($platform == 'de')
            azn_iframe.location.href = "http://www.amazon.de";
        else if($platform == 'fr')
            azn_iframe.location.href = "http://www.amazon.fr";
        else if($platform == 'es')
            azn_iframe.location.href = "http://www.amazon.es";
    }
</script>
Keyur Padalia
  • 1,944
  • 3
  • 26
  • 52

1 Answers1

2

This is not possible, because the iframe is in a different domain from yours. This limitation is a security measure imposed by the browser's same origin policy.

More reading:

Community
  • 1
  • 1
Matt Ball
  • 332,322
  • 92
  • 617
  • 683