1

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>
Cameron
  • 632
  • 9
  • 24

1 Answers1

1

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);
Badr Hari
  • 8,114
  • 18
  • 67
  • 100