0

Okey i got three iframes, and i want to have a button so i can immediately scroll to button of one of the iframe(iframe1). I think i got most of the code correct, i just dont know how to make the 'function scrollDown'

My code:

<iframe id="iframe1" src="http://examplepage1.com"><iframe>
<iframe id="iframe2" src="http://examplepage2.com"><iframe>
<iframe id="iframe3" src="http://examplepage3.com"><iframe>

<button id="scroll">Go to button</button>


<script>

var scroll = document.getElementById("scroll");

scroll.addEventListener("click", scrollDown);

function scrollDown() {

    }
Ashish Bahl
  • 1,482
  • 1
  • 18
  • 27
Mathias Hermansen
  • 261
  • 1
  • 5
  • 13
  • take a look on this answer http://stackoverflow.com/questions/4801655/how-to-go-to-a-specific-element-on-page – Ngoan Tran Jan 18 '17 at 04:42

1 Answers1

0

You can use the following:

  1. scrollIntoView() :The scrollIntoView() method scrolls the specified element into the visible area of the browser window. e.g. var element = document.getElementById("bottomDiv"); element.scrollIntoView()
  2. scrollTo() :Scrolls the document to the specified coordinates eg. window.scrollTo(0,0).
  3. scroll() :Scrolls the window to a particular place in the document. window.scroll(x-coord, y-coord) e.g. scroll(0, 100)
Pooja Kedar
  • 439
  • 2
  • 10
  • 23