def scrollToAnchor(anchor):
    """
    Function generating script to scroll to a given anchor.
    
    @param anchor name of the anchor to scroll to
    @type str
    @return script to set the style sheet
    @rtype str
    """
    source = """
(function() {{
    var e = document.getElementById("{0}")
    if (!e) {{
        var els = document.querySelectorAll("[name='{0}']");
        if (els.length)
            e = els[0]
    }}
    if (e)
        e.scrollIntoView()
    }})()"""
    return source.format(anchor)
