Skip to content

Latest commit

 

History

History
55 lines (35 loc) · 1.09 KB

File metadata and controls

55 lines (35 loc) · 1.09 KB

basic-single-page-application

a easy way to create basic single page application without even using things like router

example url

usage

  • add cdn link to your html file in end of body

    <script src="https://cdn.jsdelivr.net/gh/pushkarydv/basic-single-page-application@main/index.js"></script>
  • add a script just after cdn

  • adding pages

    give id to a section of page and then add it using inbuilt function

    <section id="page1"></section>

    you can add as many pages as you want

    addPage("page1");

    this will basically hide it from page and it will be called when url changes fir example

    https://basicspa.vercel.app/#three this page will only show section of id three other all pages added will be hidden

  • setting main page of app

    setMainPage("one");
  • finally initialize it all

    pagesInit();
  • redirect without refreshing

    <a href="#one" class="pageLink" onclick="goToPage('one')">go to one</a>