0

I came across this resource where the .js file pulls out the iframe. Source

The js file:

window.document.write("<iframe src=\"somedomain.com/page.htm\"/>");

However i'm not sure how to add attributes such as width/height/scrolling. Further more i would also like to add an image and link it as well, at the end of the iframe

0

4 Answers 4

1

You can use the same method:

window.document.write("<iframe src=\"somedomain.com/page.htm\" width='300' height='900' ></iframe>");

Note that iframe is not a self closing element tag, however most browser will render correctly. Inside the tag you can enter so alternative content incase the browser doesn't support iframes

Sign up to request clarification or add additional context in comments.

Comments

1

can you get the reference to the Frame somehow such as this.. if its the first iframe on the page then you would use index [0]

function removeScroll() { window.parent.frames[0].scrolling="no"; }

Comments

1

try using createElement, the native method

      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      IFrameObj = document.body.appendChild(tempIFrame);

      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];

Comments

0

Since this started with document.write, just continue it:

document.write("<iframe src=\"somedomain.com/page.htm\"/ width=200 scrolling='no'>");

Note that HTML doesn't actually require quotes for attributes in certain cases (see width), but they could be added just as with src. Also ' can be used in place of " and it simplifies the escaping (see scrolling). Please be consistent, the above notes are just informational.

Happy coding.

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.