ram ram
ram ram

Reputation: 37

How to pass value to url from controller?

I have a single page website where all the information are loaded in single page. All my website sections are divided by id. For example

<section id="banner">
</section>
<section id="aboutus">
</section>
    

Suppose when I load page, I want it to take me in about us section automatically. I have tried by writing 127.0.0.1:8000/#aboutus in address bar manually and it worked. Now from controller I want to pass #aboutus in url.

How can i achieve that? In my controller

public function index()
{   
   return view('landingpage');
}

How to put #abouts in url from controller?

Upvotes: 1

Views: 54

Answers (1)

Spholt
Spholt

Reputation: 4012

You can do this simply with anchor (<a>) tags within your view

<li>
    <a href="#aboutus">About Us</a>
<li/>

No javascript is required.


If you want to append the hash to the url on load, this answer may be of use

Laravel - How to redirect with hash (#)

Upvotes: 1

Related Questions