How to create a button that redirect to certain location in a website which is still on the same page?

Recommended Answers

All 5 Replies

If you can create a clickable link to a webpage, it doesn't take too much more effort to create a clickable link to a certain part of that webpage. Google "html anchor" for more info. If you can create a clickable link that takes the user where they want to go, there's not much more to make a clickable button to do so. The button will have some option to do some action when clicked. You want it to behave like a regular old link.

Now is this a Laravel question or an HTML question or perhaps it doesn't matter? If it's not a Laravel question, don't tag it with Laravel. I know nothing about Laravel, but I do know that it, like all frameworks, comes with an API and tutorials. From an HTML/Javascript/PHP with no framework point of view, what you're asking is fairly easy. My view is that IF you're a programmer, you start learning basic HTML, then proceed to basic PHP and Javascript, THEN proceed to a PHP framework. That's if you're a programmer as opposed to an artist/layout specialist. Laravel will either provide you with their way of doing this or a way to implement regular old PHP without doing it "the Laravel way". If it provides either, you should be good to go ASSUMING you know PHP and HTML and possibly Javascript at all. If it doesn't provide either and you need to do stuff like this, you might need to dump Laravel.

You can simply use HTML bookmarking to redirect visitors to a certain location on a web page. You first need to create an id bookmark like this:

<a id="faqs">Read our FAQs</a>

And then, create a link pointing to the bookmark like this:

<a href="#faqs">FAQs</a>

On the button click you redirect like this:

<button onclick="window.location.href = "https://www.example.com";">Click</button>

You can use simply on the button click you redirect one page to another page like that you can below code line
<button>Contact Page</button>

Regards
Daniel

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.