Question: I need to make sure that a specific line is visible when the user loads the page, even if that line appears many lines later in the page. In other words, when the page loads, it instantly jumps to that marked line. The line simply needs to be somewhere within the visible screen of the browser window. It is marked like this:

```
<div class="scrollhere">This line should always be visible when the page loads.</div>

```

* Only one of these appears on the whole page.
* I cannot edit the HTML marking the text, but can edit the CSS and JavaScript at the beginning of the document.
* I do not mean for just that specific line to be moved, i.e. with `position:absolute`, but that the page loads to that line.

How can I make the page load mid-way down the page, wherever a specific `<div class="scrollhere">` is found?

Answer: 
This is a pure JavaScript example. No jQuery required.

Here is a simple example of this answer in [JSFiddle](http://jsfiddle.net/h1vyye9r/).

```
window.onload = function() {
    var divs = document.getElementsByTagName("div");

    for (var i in divs) {
        if (divs[i].className.indexOf("class2") > -1) {
            //Finds top of of the element
            var top = 0;
            var obj = divs[i];

            if (obj.offsetParent) {
                do {
                    top += obj.offsetTop;
                } while (obj = obj.offsetParent);
            }

            //Scroll to location
            window.scroll(0, top);

            break;
        }
    }
};

```
This snippet may help you 

```
$('html, body').animate({
    scrollTop: ($('.class').first().offset().top)
},500);

```