3

I'm trying to get the height from an external page that is inside an embed tag with jQuery.

I also need to resize the embed tag when the content inside changes in height. I tried using the following code but it doesn't seem to work. What would be the best approach for this case?

HTML

<html>
    <body>
        <embed src="www.example.com" height="100%">
    </body>
</html>

JavaScript

$('#test').height()
$('embed').height()
AGE
  • 3,389
  • 3
  • 34
  • 56
  • Let's do some testing first: `console.log($('#test').text());`, does this work for you? How about `console.log($('embed').text());` ? – AGE Nov 20 '15 at 19:49
  • 2
    You mean *element height* instead of *tag height*, don't you? –  Nov 20 '15 at 19:54
  • Welcome to stackoverflow ;) – www139 Nov 20 '15 at 19:55
  • Can we see the HTML here? It's not clear what attribute you're trying to find exactly. – Twisty Nov 20 '15 at 19:58
  • @AGE , I tried using it but it didn't work. The result was an empty string. – Thiago Aleixo Nov 20 '15 at 20:23
  • @ThiagoAleixo it's just what you should expect unless you actually expect it to be empty. The element should contain some kind of text right? So that means your selector is not actually accessing the element,. You need to find the correct selector to use and try again, I would like to help but honestly without any HTML it's hard to guess. Does this make sense to you? – AGE Nov 20 '15 at 20:26
  • 1
    Possible duplicate of [Resizing an iframe based on content](http://stackoverflow.com/questions/153152/resizing-an-iframe-based-on-content) – Alexander O'Mara Nov 20 '15 at 20:56
  • The same issues with doing this in an iframe apply to embed tags. – Alexander O'Mara Nov 20 '15 at 20:58
  • Thanks for help, but I'm with the problem yet. My Html code is something like this: Analysing the html rendered, this embed has a #document, and I think that for this #document I won't get a height of the embed Height="100%" does't work too, only width="100%". – Thiago Aleixo Nov 21 '15 at 00:08
  • heights defined to percent are relative to parents, not to childrens. Try defining `html, body { height: 100% }` first – Marcos Pérez Gude Nov 23 '15 at 15:14

1 Answers1

1

After some hours I solved my problem with this:

cross domain

This saved my integration from my application in asp.net with WordPress.

Thanks for everybody that tried help me.