how to link to a specific part of a page html code example

Example 1: javascript redirect

window.location.href = "http://mywebsite.com/home.html";

Example 2: html a link to section on page

<!--1. create link tag with href containing "[#][section to direct] with name-->
<a href = #about-section>About</a>

<!--2. create identifier for the section you would like to navigate to with "id" = name-->
<section id = "about-section"> <h1>This is the about section</h1> </section>

Example 3: javascript get all script tags on page

var scripts = document.getElementsByTagName("script");
for (var i = 0; i < scripts.length; i++) {
  if (scripts[i].src) {
  	console.log(i, scripts[i].src);
  } else { 
    console.log(i, scripts[i].innerHTML);
  }
}

Example 4: link to section on page html

<!-- #top is the ID of the div where u wanna link to -->
<a href="#top">Go back to the top!</a>

<div id="top"></div>

Example 5: link that scrolls down the page

<a href="#google"></a>

<div id="google"></div>

Example 6: how to redirect to another page in javascript on submit type

<script type="text/javascript" language="javascript">
function redirect()
{
    window.location.href="login.php";
}
</script>
<form  name="form1" id="form1" method="post">  
    <input type="submit" class="button4" name="order" 
        id="order" value="Place Order" onclick="redirect();" >
</form>

Tags:

Css Example