Php

JavaScript Open url in new tab

This quick JavaScript tutorial help to open a linked URL in a new browser window or tab. The HTML is anchor '<a>' tag that ll use to open a URL into the new tab using JavaScript.

HTML a target attribute provides an easy way to open a URL into the new browser window or tab. We’ll use _blank value in the target attribute to open the linked URL in a new tab or window.

<a href="https://phpflow.com" target="_blank">Visit Phpflow</a>

Above code, ll open phpflow.com into the new tab using pure HTML.

But If you want to open a URL with JavaScript. The JavaScript window.open() method is used to open a new browser window depending on the browser setting and the parameter values.

Related Post

You can pass _blank as the second parameter into the window.open() method to open a URL in a new tab using JavaScript.

The following JavaScript code will open https://phpflow.com in a new browser tab or window.

window.open('https://phpflow.com', '_blank');

Full Source Code:

<html> 
  
<body> 
  
    <p>Click the button to open a new tab </p> 
  
    <button >

Recent Posts

Configure and Retrieve S3 Information Using Laravel PHP-AWS-SDK

This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More

2 months ago

What is the Purpose of php_eol in PHP?

in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More

8 months ago

Laravel Table Relationship Methods With Example

This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More

8 months ago

Exploring the Power of Laravel Eloquent Join?

We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More

9 months ago

Quick and Easy Installation of Laravel Valet

in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More

9 months ago

What is Laravel Soft Delete and How Does it Work?

I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More

9 months ago

Categories