A JavaScript plugin that scrolls to the element with the ID specified in the URL hash on page load.
To use this plugin, simply include the initialScrollPlugin.js
file in your HTML file:
<script src="initialScrollPlugin.js"></script>
To use the plugin, call the initialScrollPlugin()
function with an optional offset
parameter:
initialScrollPlugin({offset: 50})();
The offset
parameter specifies the number of pixels to offset the scroll position by. By default, the offset is 0.
Here's an example of how to use the plugin:
<!DOCTYPE html>
<html>
<head>
<title>Initial Scroll Plugin Example</title>
</head>
<body>
<h1 id="heading">Hello, world!</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<script src="initialScrollPlugin.js"></script>
<script>
initialScrollPlugin()();
</script>
</body>
</html>
In this example, the plugin will scroll to the element with the ID heading
on page load.
This plugin is released under the MIT License.