Fix position of a page

Asked

Viewed 113 times

1

I have a page that inside it has another, this internal page is placed in an iframe, I need it to stay in a certain position and not the whole one. width="250" height="350" scrolling="no" . I can’t do this in iframe because I don’t have permission so I put this iframe inside a div. I’ve tried that but it doesn’t 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 fix the vertical position of this page included in the other, because I just want to show the user only one frame that does a certain function.

  • Then you need to apply CSS. Can you explain the scenario you have and how you want it to look? and what you’ve tried?

  • I have a page that inside it has another, this internal page is placed in an iframe, I need it to stay in a certain position and not the whole one. width="250" height="350" scrolling="no" . I can’t do this in iframe because I don’t have permission so I put this iframe inside a div. Já tentei isso mas não funciona var frm_doc = document.getElementById("frm");
 //frm_doc.documentElement.scrollTop = 500; 
 //document.getElementById("frm").contentWindow.scrollTo(100, 500);
 frm_doc.contentWindow.scrollTop(500, 500);

  • 1

    According to Sergio. We need to know for example who belongs to the pages. The 1st is on the server of vc? And the second? And why do you want to show only one part? In case it shows only one element, I think it’s best to read the page in PHP, filter data and then send with echo what you want to show. But it depends a lot on the situation. So try to explain better so that we can help better. :)

  • The first yes is on my server and the second no, it has a function on a button I need. I just need this button to stay on mine and use it.

1 answer

1


If you are not allowed to do this within the iframe then you need to change the iframe position within the div that involves her.

In that case I suggest you position: relative; the div that is around the iframe and position: fixed; to iframe itself. There you can do so 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: http://jsfiddle.net/aergmkwv/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.