scrollIntoView

Greetings ,
I would like to cause
[div id=“scrollThis”]
to ScrollIntoView
according to
[td id=“asThisScrolls”]
But so far , no go .
Pls , what am I doing wrong ?
Thanks for your help…

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>scrollIntoView.html</title>
<style>
.button {
         background-color:#5A697D;
         border: none;
         color: #E09F1F; 
         text-align: center;
         text-decoration: none;
         display: inline-block;
         font-family: Tahoma; font-size: 24px;
         cursor: pointer;
         }
         h3 h4 {
         color:#5A697D;
		 }
.divRow {
         color:#5A697D;
}	

#asThisScrolls {
         
}

#scrollThis {
         
}
</style>
</head>
<body style="background-color:#EBE8E4; font-family: Tahoma; font-size:20px;  color:#5A697D;;" link="#5A697D;" alink="#5A697D;" vlink="#5A697D;">

<table style="text-align: left; width: 100%; height: 100%; border-color: #E09F1F; border-style: solid; border-width:4px;">
<tbody>
<tr>
<td  style="vertical-align: top; text-align: center;  width: 25%; border-color: #E09F1F; border-style: solid; border-width: 2px;" > <!--  -->
<br>

<div id="scrollThis" style=" text-align: center; ">
    <br><a href="http://automatonnation.us/Automata-Examples.html" target="_blank">
                        <button class="button">Automatons</button></a>
    <br><br><a href="http://vmars.us/freeware/index.html" target="_blank">
                        <button class="button">Freeware</button></a>
    <br><br><a href="http://vmars.us/reads/ListenReadWatch.html" target="_blank">
                        <button class="button">Listen/Read/Watch</button></a>
	<br><br><br><br>			
</div>
</td>


<td id="asThisScrolls" style="vertical-align: top; width: 75%;">
<br>
<div  style=" text-align: center; color:#5A697D;">
           <button class="button">Freeware</button></a>
    <br><br>
</div>

<div  style=" text-align: center; color:#5A697D;">
<a href="http://kidsafebrowser.us/Read-Documentation-Here.html" target="_blank"> 
<h3 style="color:#5A697D;">KidSafeBrowser</h3>
</a>

<a href="http://kidsafebrowser.us/Read-Documentation-Here.html" target="_blank"> 
<h3 style="color:#5A697D;">Read-Documentation-Here.html</h3>
</a>
<h4  style="color:#5A697D;">
<br> KidSafeBrowser is a Free Internet Browser , based on MS Edge (Chromium) Browser .
<br> 'Safe' , because users can only visit sites that are Pre-Approved and stored in an Approved-Links-File .
<br> This makes it ideal for Kids as well as Businesses .
<br> The package can be Downloaded here:
<br> https://sourceforge.net/projects/kidsafebrowser-us/
</h4>
</div>

<div class="divRow" style="text-align:center; color:#5A697D;">
<br>
<a href="https://www.portablefreeware.com/index.php?id=2412#post" target="_blank">
<h3 style="color:#5A697D;">Screenshot Captor</h3> 
</a>
<h4  style="color:#5A697D;">  Screenshot Captor is a feature-rich image tool for grabbing, manipulating, annotating, and sharing images. 
</h4>
</div>

<div class="divRow" style="text-align:center; color:#5A697D;">
<br>
<a href="https://www.portablefreeware.com/index.php?id=1856#comment31802" target="_blank">
<h3 style="color:#5A697D;" >Instant Eyedropper</h3>
</a>  
<h4  style="color:#5A697D;">  Instant Eyedropper is a simple color picker that sits in the system tray. 
</h4>
<br>
</div>

<br>  

<div class="divRow" style="text-align:center;">
<a href="https://vmars.us/freeware/Line-By-Line/Line-By-Line_HELP.html" target="_blank">
<h3 style="color:#5A697D;">Line-By-Line</h3>
</a> 
<h4 style="color:#5A697D;">  'Line-By-Line' is a text manipulation program <h5>(secondarily , also a basic Text Editor) .</h5></h4>
</p>
</div>
<br>

<div class="divRow" style="text-align:center;">
<h3 style="color:#5A697D;">  PimClip/PimFind </h3>
<h5>Formerly called ClipLog/ClipFind</h5>
<h3  style="color:#5A697D;">is my 'Personal Info Manager' . Easy to use , fast , and powerful . </h3>
<a href="https://vmars.us/freeware/PimClip/PimClip-Help.html" target="_blank">
<h3 style="color:#5A697D;">PimClip</h3> 
</a> 

<a href="https://vmars.us/freeware/PimClip/PimFind-Help.html" target="_blank">
<h3 style="color:#5A697D;">PimFind</h3>
</a> 
</div>
<br>

<div class="divRow" style="text-align:center;">
<h3 style="color:#5A697D;">FreshDraft </h3>
<br>
</div>
<br>

<div class="divRow" style="text-align:center;">
<h3 style="color:#5A697D;">Guitar-Scales-and-Boxes-Builder</h3>
<br>
</div>
<br>

<div class="divRow" style="text-align:center;">
<h3>Html-Grid-Builder </h3>

</div>

</div>
</td>
</tr>
</tbody>
</table>
<br>

    <div>
        <p style="text-align:center;">
        <span style="font-size: 14pt; font-family: &quot;Avenir Next&quot;;">
<br><br> <a href="http://vmars.us/">  http://vmars.us/  </a>
      </span>
            <br>
            <br>"All things in moderation , except for love and forgiveness"
            <br>
        </p>
    </div>

<script>
const element = document.getElementById("#scrollThis");
window.addEventListener('scroll' , scrollToBottom);

function scrollToBottom() {
console.log("function scrollToBottom()");
element.scrollIntoView(false);
} 

</script>

</body>
</html>

Would this help you out?

getElementById doesnt take the #.

That’s not going to work (even with corrected code) as you can’t scroll table-cells and I don’t think that’s what you wanted anyway.

If you just want to keep the ‘Automatons/Freeware/Links’ in view while the right panel scrolls up and down then you don’t need any JS as you can do it like this.

#scrollThis{
  position:-webkit-sticky;
  position:sticky;
  top:0;
}

Note that you really shouldn’t be using tables for layout these days or inline styles (even for demos) as that makes life just too hard :slight_smile:

Just as an example I quickly converted that page so that it doesn’t use tables. I know this wasn’t your original question but would be remiss of me not to mention it.

It still needs the structure thinking about as there are too many headers without any content. The links should probably be lists. target="_blank" should be avoided as it should be the users choice. Also note that you are not allowed in html to put buttons inside anchors (or vice versa) as you can’t have two interactive sets of content! Which one should the browser choose the link or the form submission?

I don’t expect you to copy and use it but just something to work towards in the future.:slight_smile:

Thanks Paul , Great Help.

1 Like

Thanks m_hutley

Thanks ladans37

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.