html - How to properly scroll IFrame to bottom in javascript -


For a fake-webpage used to research interactions on websites, I used a javascript to send a mockup message -Stream made This message stream is loaded in an iframe and should show images at pre-determined intervals and by placing a new image on the bottom of the page, scroll down to the bottom of the page. The images are working very well with the available script to display. However, both Chrome and IE have trouble scrolling down the page. As soon as the image is attached, I would like to scroll down to the bottom of the page, but now it has added a delay of 5 miles because it seems that sometimes my questions are:

  • Is it okay to use document.body.scrollHeight for this purpose?
  • Can I scroll straight away, or do I need a small gap before scrolling?
  • After adding an image, how is the code to scroll down to the bottom of the iframe?

    The following function is used and trypost () starts onLoad:

      function scrollbotm () {window.scrollBy (0, document .body.scrollHeight); } Function trypost () {point = point + 1; If (point & lt; interval.length) {// create and attach a new image var newImg = document.createElement ("IMG"); NewImg.src = "picture /" + picture [point] + ".png"; document.getElementById ('holder') appendChild (newImg). // to create and add a return variable = document.createElement ("br"); document.getElementById ('holder') appendChild (br). // Scroll down time (after an arbitrary 5 seconds) var stb = window.setTimeout (scrollToBottom, 5); // time next post var nextupdate = interval [point] * 400; Var tp = window.setTimeout (trypost, nextupdate); }}   

    My script section contains at least the following variables:

      var point = -1; Var interval = [10, 10, 15]; Var images = ["R1", "A1", "R2"]; The continuation of the project described in   

    this question

    is scroll down It's always to scroll on some ridiculously large top offsets, like 99 9999 .

      iframe.contentWindow.scrollTo (0, 999999);   

    Also see this post:

    If scrolling is coming very quickly, then images may not yet be loaded. In this way, you will have to scroll soon, such as to keep it instead of the added image is loaded

      newImg.onload = function () {triggerScrolling (); }; After creating  newImg , but before specifying the property,  src .  

    If there are many events required to trigger scrolling you may need to use some "Event Collector".

      function getEventCollector (start, trigger) {return function () {if (--start == 0) {trigger (); )}; }   

    You can then use it like this:

      var collector = getEventCollector (2, function) {triggerScrolling ();}); NewImg.onload = Collector; Window.setTimeout (Collector, 100);   

    In this way trigger scrolling () at least and 100ms after image loading for collector triggers scrolling to resume () is to be invoked eventually.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -