I am attempting to make a 5-star rating extension, that makes 5 star's appear on a certain web-page, and gather data on how many user's have rated, and the average rating. I made a .php page with two div tags named 'total' and 'star' - with the total of ratings and the average rating, in which I create an iFrame that opens that page.
When I attempted to grab the data, using
totalrating = $('#getrating').contents().find('#total').html();
( getrating = the iframe, total = the div tag with the total of ratings )
it returns null. Is there something wrong I am doing? The page that the 5 stars are going on is a different web-site than mine, so I see no other way than using an iFrame.
Thanks, Alex.
The function 'contents()' can get the content only if the iframe exist in the same domain.
maybe this help:
http://pipwerks.com/2008/11/30/iframes-and-cross-domain-security-part-2/
也许这可行:
totalrating = $(document.getElementById('getrating').contentDocument).find('#total').html();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.