title: How do I fallback from scrollIntoViewOptions for compatibility with Safari?
body: <p>I have an onclick that triggers this function:</p>
  <pre><code> function thread2M() {
          
    var elmnt = document.getElementById(&quot;scroll2&quot;);
    elmnt.scrollIntoView({behavior: &quot;smooth&quot;, block: &quot;center&quot;, inline: &quot;center&quot;});
  
  }
  </code></pre>
  <p>which scrolls the page to a particular pixel (a div) and centers it. Of course, scrollIntoViewOptions doesn't work in Safari, so I'd like to fall back to scrollIntoView() or scrollTo().</p>
  <p>I've tried:</p>
  <pre><code>function thread2M() { 
      var elmnt = document.getElementById(&quot;scroll2&quot;);
      try {
          elmnt.scrollIntoView({behavior: &quot;smooth&quot;, block: &quot;center&quot;, inline: &quot;center&quot;});
  }    catch {
          elmnt.scrollIntoView(true);
  }
  }
  </code></pre>
  <p>and</p>
  <pre><code>function thread2M() {
              if (typeof document.body.scrollIntoView === 'function') {
    var elmnt = document.getElementById(&quot;scroll2&quot;);
    elmnt.scrollIntoView({behavior: &quot;smooth&quot;, block: &quot;center&quot;, inline: &quot;center&quot;});}
  
    else {window.scrollTo(782, 280);}
   
  }
  </code></pre>
  <p>but no scroll is initiated. I don't even have basic knowledge of how JS works, so the answer is probably related to fundamentals, but I can't find the solution out there. I think I just need to test if scrollIntoViewOptions works, if true, run one script, if false, run another.</p>
  <p>Answers appreciated, thank you.</p>