1

I want to change the content of Iframe. but when I use document.open in Iframe then my main page get scroll down bottom automatically.

 d.idoc.open('text/html', 'replace');
 d.idoc.write(text);
 d.idoc.close()

This issue is reproducible in safari and chrome mostly.

Ritesh Chandora
  • 8,382
  • 5
  • 21
  • 38

1 Answers1

-1

First of you should take care of CORS Errors, because normally trying to get or change something within an iframe will be blocked by the browser duo same-origin policy.

if idoc is your iframe, do this:

idoc = idoc.contentWindow;

This should be the solution if you have no same-origin problems.

Also read this if you need further information: Ways to circumvent the same-origin policy

edit

Regarding the comments, the question is something like: "Why is the page scrolling down?"

Current possibility: If the event got triggered within an <a>Tag and the Tag ahs a #ID in the href, the page will try to scroll to this position.

{edit follows after clearing facts with author - waiting for more input}

Community
  • 1
  • 1
Cagatay Ulubay
  • 2,491
  • 1
  • 14
  • 26