Javascript Popupwindow图像链接和css文件
如何在弹出窗口中放置图像并将其链接到CSS文件?假设我想在我的计算机上插入一个名为Javascript Popupwindow图像链接和css文件,javascript,html,css,Javascript,Html,Css,如何在弹出窗口中放置图像并将其链接到CSS文件?假设我想在我的计算机上插入一个名为big.jpg的图像。这可以通过简单的Javascript代码实现吗 popupWindow.document.writeln('<html><head>'); popupWindow.document.writeln('<link rel="stylesheet" type="text/css" href="tressider.css" />'); popupWindow.do
big.jpg
的图像。这可以通过简单的Javascript代码实现吗
popupWindow.document.writeln('<html><head>');
popupWindow.document.writeln('<link rel="stylesheet" type="text/css" href="tressider.css" />');
popupWindow.document.writeln('</head><body>');
popupWindow.document.writeln('<h2 class="pp">'+help[3].office+'</h2>');
popupWindow.document.writeln('<p></p>');
popupWindow.document.writeln('<h3 >'+'725-0911'+'</h3>');
popupWindow.document.writeln('<p></p>');
popupWindow.document.writeln('<div class="wocao">'+help[3].Description+'</div>');
popupWindow.document.writeln('</body></html>');
popupWindow.document.bgColor="White";
popupWindow.focus();
popupWindow.document.close();
popupWindow.document.writeln(“”);
popupWindow.document.writeln(“”);
popupWindow.document.writeln(“”);
popupWindow.document.writeln(“”+help[3].office+“”);
poppwindow.document.writeln(“”);
popupWindow.document.writeln(“+”725-0911“+”);
poppwindow.document.writeln(“”);
popupWindow.document.writeln(“”+help[3]。说明+“”);
popupWindow.document.writeln(“”);
popupWindow.document.bgColor=“白色”;
popupWindow.focus();
popupWindow.document.close();
是的,这可以通过直接在窗口中添加样式和img元素轻松完成
只需使用:
var _image = popupWindow.document.createElement('img');
_image.setAttribute('width',#);
_image.setAttribute('height',#);
_image.setAttribute('src',"myimg.png");
popupWindow.document.appendChild(_image);
并对样式标记执行相同的操作
var _style = popupWindow.document.createElement('img');
_style.setAttribute('src',"mystyle.css");
popupWindow.document.appendChild(_style);
非常感谢TootsieRoller,我现在将尝试它。我是否应该将这些代码放在popupwindow.document.close上方并放在函数内部?是的,将其放在常规网页中您希望的任何位置。您希望将该图像插入何处?