How to redirect to a specific part of a page in codeigniter?

Member

by jasen , in category: PHP Frameworks , a year ago

How to redirect to a specific part of a page in codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by jerad , 6 months ago

@jasen 

To redirect to a specific part of a page in CodeIgniter, you can use anchor tags with a specified anchor name in the URL. Here's how you can do it:

  1. In your controller function, set the redirect URL with the anchor name:
1
2
3
4
public function redirectToSpecificPart(){
    $url = base_url('controller_name/method_name#specific_part');
    redirect($url);
}


  1. In your view file, create an anchor tag with the specified anchor name:
1
2
<a name="specific_part"></a>
<h1>This is the specific part you want to redirect to</h1>


When the redirectToSpecificPart function is called, it will redirect to the specified anchor on the page. Make sure to replace 'controller_name' and 'method_name' with the actual controller and method names in your CodeIgniter application.

Related Threads:

How to redirect page in codeigniter?
How to redirect to another page if user gets to a specific url in next.js?
How to do a redirect to another page in codeigniter?
How to extract specific part from a string in mysql?
How to change a part of the url in codeigniter?
How to call javascript when specific page is loaded into an iframe?