最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to get an element outside of iframe with javascript or jQuery? - Stack Overflow

programmeradmin2浏览0评论

I'm trying to get a element from outside of iframe with js or jQuery. I found something but it's not cross browser.

<div id=vi-desc-maincntr"">
    <div class="u-flL iti-act-num">123456789</div>
    <div id="desc_div">
        <iframe src="LOCATION">
    </div>
</div>

I need that number into a variable.

I'm trying to get a element from outside of iframe with js or jQuery. I found something but it's not cross browser.

<div id=vi-desc-maincntr"">
    <div class="u-flL iti-act-num">123456789</div>
    <div id="desc_div">
        <iframe src="LOCATION">
    </div>
</div>

I need that number into a variable.

Share Improve this question edited Mar 30, 2016 at 17:55 Termininja 7,03612 gold badges50 silver badges50 bronze badges asked May 28, 2014 at 14:07 Adrian AxinteAdrian Axinte 1791 gold badge2 silver badges16 bronze badges 3
  • Are the iframes in the same [sub]domain? – enapupe Commented May 28, 2014 at 14:08
  • nope. it's the iframe for description in ebay – Adrian Axinte Commented May 28, 2014 at 14:10
  • 1 please check this stackoverflow.com/questions/18356533/… – Shiva Srikanth Thummidi Commented May 28, 2014 at 14:14
Add a comment  | 

1 Answer 1

Reset to default 24

Same-origin policy:
You might want to check this. Two pages need to have the same origin.
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy


If your child page is located at same domain as parent page, You can write a code like below in the child window :

 $('#test1', parent.document).html('<h1>clicked</h1>');

The second parameter provides the context in which to search the element matched by the first parameter. The Document is here:http://api.jquery.com/jQuery/#jQuery-selector-context

 jQuery( selector [, context ] )

Hope this helps.

发布评论

评论列表(0)

  1. 暂无评论