Link to home
Start Free TrialLog in
Avatar of Luey
LueyFlag for United States of America

asked on

easyXDM resize iframe based on content still shows scroll bar

I am trying to use easyXDM to resize an iframe based on its content (cross domain).  I can make it all work except that it still leaves a scroll bar.  Here is my test code.
Test Page

Code for the page to embed the iframe
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="/javascript/easyXDM.min.js" type="text/javascript"></script> 
</head>

<body>

<!-- use css to style this and its contained iframe --><div id="container"></div>


<script type="text/javascript">
new easyXDM.Socket({
    remote: "https://prizemagnet.com/giveaway_widget_2.php?giveaway_id=288",
    container: document.getElementById("container"),
    onMessage: function(message, origin){
        this.container.getElementsByTagName("iframe")[0].style.height = message + "px";
		this.container.getElementsByTagName("iframe")[0].style.width = "650px";
    }
	
});
</script>


</body>
</html> 

Open in new window


Code for the document to be embeded
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<link href="/support/giveaway_widget.css" rel="stylesheet" type="text/css" />
 <script src="/javascript/easyXDM.min.js" type="text/javascript"></script>
</head>

<body>
<div id="giveaway_entry_box">test</div>
</body>
<script type="text/javascript">
    var socket = new easyXDM.Socket({
    onReady:  function(){
        socket.postMessage(document.body.scrollHeight)
   }
});
</script>
</html>

Open in new window

Avatar of leakim971
leakim971
Flag of Guadeloupe image

where is the scrollbar ?
User generated image
ASKER CERTIFIED SOLUTION
Avatar of Luey
Luey
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
accept your own solution
Avatar of Luey

ASKER

I found this in the easyXDM examples and it cured my problem.