0

I have a website on which i overlay a div element for some purpose. Now instead of overlaying i want to push the webpage and have all the divs inside an iframe.

I have created the iframe but am not able to append the div inside the iframe.

EDIT:

var iframepush = document.createElement('iframe');
                        iframepush.frameBorder=0;
                        iframepush.scrolling="yes";
                        iframepush.id="crossrider-siderbar-iframepush-26337";
                        iframepush.allowTransperancy="true";
                        iframepush.style.position='fixed' 
                        iframepush.style.right = '0px';
                        iframepush.style.top = '0px';
                        iframepush.style.position = 'absolute';
                        iframepush.style.height = $(window).height() + 'px';
                        iframepush.style.width = '150px';
                        iframepush.style.display = 'inline-block';

                        document.body.appendChild(iframepush);

                        var rightDiv = iframepush.document.createElement("div");
                        rightDiv.className = "crossrider-sidebar-26337 crossrider-sidebar-26337-container ";
                        rightDiv.style.cssText = "display: block; position: fixed; right: 0px; top: 0px; width: 150px; height:" + $(window).height() + "px; z-index:970; ";
                        iframepush.document.body.appendChild(rightDiv);
1
  • Please post the code you've tried using. Commented Apr 4, 2013 at 14:44

1 Answer 1

1
  <script type="text/javascript">
    $(document).ready(function() {
      $("#iframeId").contents().find("body").html($("<div></div>").append($("#test")).html());
    });
 </script>
 <iframe id="iframeId" name="iframeId" src="about:blank" ></iframe>
<div id="test">
   Text
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.