JavaScript Open Url in New Tab


JavaScript Open Url in New Tab : We sometimes need to open url in new tab using the javascript. There are many ways to do this. Here in this tutorial we are going to follow the simple example. We are going to explain how you can open url in new tab using javascript. We will explain this functionality with example and online demo with our online editor.


JavaScript Open Url in New Tab Example

Let us create a simple function which will redirect to the given url.

JavaScript Open Url in New Tab:

<script type="text/javascript">
function OpenUrl(url) {
  var winObj = window.open(url, '_blank');
  winObj.focus();
}
</script>

Try it »

If you run the above example it will produce output something like this and when you click on link it will open the url in the new tab.

JavaScript Open Url in New Tab Example


Advertisements

Add Comment

📖 Read More