<a> tag defines a hyperlink. By default, it opens the target URL in the same tab. This default behavior can be changed in one of two ways.
The simplest way is using the
target attribute. The
'_blank' tells the browser to use a new window or tab. However, most browsers default to using a new tab instead of a new window.
window object represents the browser window. The
open() method of the
window object can be used to create a new window.
window.open(url, target, windowFeatures);
The parameters of
window.open method are as follows:
url: The URL to load.
target: The context name to use for the new window.
windowFeatures: A comma-separated string of additional options.
this.href: It refers to
href, the URL already specified in
'new': It is an arbitrary value for the
'popup': It is one of the
windowFeaturesthat ensures a new window is opened for a hyperlink.
return false; makes sure the original window is not redirected.
View all Courses