Do you know you can earn heaps of $$ by answering questions on kodlogs, for more info contact us through feedback link at footer? We are Australian based web site and pay you for answering questions

  • Register
Welcome to Kodlogs Q&A, where you can ask programming questions and receive answers from other members of the community. For programmers, by programmers Kodlogs is an open community for anyone that does coding. We help you get answers to your toughest coding questions, share knowledge with your coworkers in private, and find your next IT dream job.
0 votes
I want to open a new tab/window and do some writing of custom HTML on it?

I tried following with fails:'','','width=500,height=200')

myWindow.document.write("<p>Hello 'World'</p>")


I also tried:'<html><head></head><body>'Hello World'</body></html>');

Can anyone show me what wrong i am doing?
by (930 points)  

2 Answers

0 votes

How to Open URL in New Tab using JavaScript with Content

javascript open new tab with content

We have been using <a> tag of HTML to open a new link URL but there might be need to open a new tab with content using Javascript. How do we do this?

Using method we can open a URL in a new tab.'', '_blank');

by (930 points)  
edited by
0 votes

More Example to open a new tab with content or without content in Javascript:


Open "" in a new browser tab:"");

Definition of open

This method opens browser in new window or a new tab based on your browser capabilities set up.

Browser Supported

IE, Chrome, Safari, Firefox

Syntax for open, name, specs, replace)


var myWindow ="", "", "width=100,height=50");


Showingopening a new window and writing content on it

var win ="", "MsgWin", "width=100,height=50");

myWindow.document.write("<p>Hello World</p>");


Replacing exisitng window with a new window:

var win ="", "_self");

myWindow.document.write("<p>Replacing exisitng window.</p>");


Appearance of new window:"", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=400,left=400,width=300,height=300");


multiple tabs opening windows with:"", "width=);"");


Example of close() for closing the window:

function openWin() {

  win ="", "win", "width=200,height=100");   // opening new window


function closeWin() {

  win.close();   // Closing the new window



Using the name property to return the name of the new window:

var win ="", "Msgwin", "width=100,height=80");

myWindow.document.write("<p>Hello World"</p>");

by (930 points)