Javascript Open Link in New Window Example
Hi Dev,
In this blog, I will learn you how to open link in new window using javascript. I would like to take the current page URL and open it in a new window.
I will give you simple and easy example for open link in new window using javascipt is bellow. you can see a simple example of open url in new window using window.open() in javascript.
Syntax :
window.open(URL, name, specs, replace);
Use :
window.open("/","mywindow","status=1,toolbar=1");
Example
<!DOCTYPE html>
<html>
<head>
<title>javascript open link in new window example - nicesnippets.com</title>
</head>
<body>
<h1>NiceSnippets.com</h1>
<button onclick="getLink();">Click me</button>
<script type="text/javascript">
function getLink() {
window.open("/","mywindow","status=1,toolbar=1");
}
</script>
</body>
</html>
It will help you...
- How to set Date in setUTCHours() Method in JavaScript?
- How to Date sets UTC milliseconds in Javascript?
- How to Use push(), unshift(),pop() and shift() With Array in Javascript?
- How to Check if a Variable is a Number in Javascript?
- How To Format a Number Using Fixed - Point Notation in Javascript?
- How to Insert an Element into an Array in javaScript?
- How to remove duplicate elements from JavaScript Array?
- How to calculate years, months and days between two dates in javascript?