0

I am clearly being stupid. Please see below and tell me where I am losing it :-(

Html layout

<div class="the-variables">
  <span class="asking">156.25</span>
  <span class="bidding">144.82</span>
</div>

iFrame Layout

<iframe id="livetick" style="overflow-y: hidden;" src="http://dev.aatsol.co.za/live-feed/" scrolling="no" seamless onload="window.parent.scroll(0,0);" height="370" width="370" frameborder="0">
&lt;p&gt;Your browser does not support iframes&lt;/p&gt;
</iframe>

And this is my javascript attempt

jQuery( document ).ready(function($) {
    
    
    var iframe = document.getElementById('livetick');
    /* var innerDoc = iframe.contentDocument || iframe.contentWindow.document; */
    var innerDoc = iframe.contentWindow.document.getElementsByClassName('asking');
    //alert (innerDoc.innerHTML);
    //alert (innerDoc);
    console.log(innerDoc);

});

For some strange reasons I fail to pull the two values from within the provided spans. They are handled on a remote website fluctuate based on various factors. I simply want to pull them on my website in a iFrame and copy the two values fro inside the iFrame to a section on my website footer.

In short: 1. Get values inside iFrame 2. Copy exact values to a section on my website footer (using jQuery / javascript)

1
  • Did you look if the console outputs something? Commented May 19, 2015 at 8:49

1 Answer 1

1

Based on the URL of your iframe, you're running into the Same Origin Policy, which prevents cross-origin access to the document. You can't access the DOM of a window that isn't from the same origin as the document you're trying to access it from.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @T.J Crowder!! I owe you a beer :-(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.