Fix position of a page

1

I have a page inside it that has another one, this inner page is placed in an iframe, I need it to be in a certain position and not the whole one. width="250" height="350" scrolling="no". I can not do this in iframe because I am not allowed so I put this iframe inside a div. I've tried this but it does not work:

var frm_doc = document.getElementById("frm"); 
//frm_doc.documentElement.scrollTop = 500;
//document.getElementById("frm").contentWindow.scrollTo(100, 500); 
frm_doc.contentWindow.scrollTop(500, 500);

The problem is that I need to set the vertical position of this page included in the other, since I only want to show the user only a frame that does a certain function.

    
asked by anonymous 08.10.2014 / 16:22

1 answer

1

If you are not allowed to do this within the iFrame then you have to change the position of the iFrame within the div that surrounds it.

In this case, I suggest that you give position: relative; to the div that is around iFrame and position: fixed; to the iFrame itself. Here you can do this with JavaScript: (if you do not want to do with CSS that is still bad)

document.querySelector('iframe').style.top = '-300px'; // ou outro valor que queira

Example: link

    
08.10.2014 / 17:48