这是我的代码,我想在下面添加一张图片:
function createWindow() {
var myWindow = window.open("", "MsgWindow", "width=500,height=500");
myWindow.document.write("<h1>A test: </h1>" +
" <p> <b>Something bold: </b> text </p>");
// I want to add an image here (inside the widow) but I'm not sure how
}
您可以将图像添加到myWindow
的html文档中,如下所示:
myWindow.document.write("<img src='https://i.imgur.com/RUKhJjI.png' width=256 height=256>");
function createWindow() {
const myWindow = window.open('', 'My New Window', 'width=500,height=500')
myWindow.document.body.innerHTML = `
<h1>A test:</h1>
<p> <b>Something bold: </b> text </p>
<img src="https://i.imgur.com/qVr8o7q.jpeg" />
`;
}