How to open a link in new window with laravel?

Member

by adan , in category: PHP Frameworks , 8 months ago

How to open a link in new window with laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by elise_daugherty , 8 months ago

@adan 

To open a link in a new window using Laravel, you can use the target="_blank" attribute in your anchor tag. Here's an example:

1
<a href="https://www.example.com" target="_blank">Click here</a>


In this example, when the user clicks on the link "Click here", it will open the specified URL in a new browser window.


If you are generating links dynamically in your Laravel application, you can use the Html facade to create the link with the target="_blank" attribute. Here's an example:

1
2
3
4
use IlluminateSupportHtml;

$link = Html::link('https://www.example.com', 'Click here', ['target' => '_blank']);
echo $link;


This will generate the same HTML anchor tag with the target="_blank" attribute set.


Remember to always include the target="_blank" attribute responsibly, as opening links in new windows can potentially lead to a poor user experience for some users.

Related Threads:

How to open a link in a pop up iframe window?
How to open a iframe link within the same iframe?
How to open google map link in iframe?
How to open external link in elementor popup?
How to count number of clicks on link in laravel?
How to force laravel to generate https link?