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 开发者_Go百科would also like to add an image and link it as well, at the end of the iframe
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
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"; }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'];
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.
精彩评论