Cameron
Cameron

Reputation: 671

access external html body's width and height with javascript and/or jquery

I am using the fancybox plugin to open up an html file in the fancybox popup. How do I access the external html files width and height using javascript/jquery. My external html looks something like this:

<html>
<head>
<style type="text/css">
body {
  width:500px;
  height:500px;
  background-color:red;
}
</style>
</head>

<body>
<p>TEXT_TEXT_TEXT</p>
</body>
</html>

Upvotes: 1

Views: 362

Answers (1)

Badr Hari
Badr Hari

Reputation: 8424

I guess FancyBox will load the html file in iFrame, then it would be something like that:

This goes to your html file (which is being used in iframe):

window.myFunction = function(width, height) {
 //change body width
 //change body height
}

And like that you can access the function in iframe

document.getElementById('YOURFRAMEIDHERE').contentWindow.myFunction(args);

Upvotes: 1

Related Questions