弹出窗口图像链接和css文件
Popupwindow image link and to css file
如何将图像放在弹出窗口上并链接到CSS文件?假设我想在我的计算机上插入一个名为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();
是的,这可以通过直接向窗口中添加样式和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);
相关文章:
- 如何修复:当javascript更改DOM时,iOS会删除CSS文件
- 使用Javascript读取CSS文件并动态更改页面
- js和css文件-在publichtml外部或内部
- Google PageSpeed Insights与多个CSS文件
- Javascript:动态更改CSS文件+Cookie
- 没有在django项目中加载CSS文件
- 在企业应用程序框架中包含js/css文件的最佳实践是什么
- Chrome审核:在外部CSS文件之间的头中发现了1个内联脚本块&”;
- 使用新的 CSS 文件覆盖当前网站
- 多余的JS和CSS文件
- 快递.js无法获取我的 CSS 文件
- 无法查找元素'手动加载CSS文件时的CSS属性
- jquery移动应用程序无法使用jquryMobile框架JS和css文件的相对路径
- 不同的引导 CSS 文件
- 加载CSS文件并覆盖上一个文件
- 使用 JavaScript 动态加载 CSS 文件
- 如何使用谷歌页面速度CSS加载脚本延迟多个CSS文件
- 在 html 文件中包含无缓存元标记是否也会阻止缓存该 html 文件中链接的 js 和 css 文件
- Spring MVC 集成 js 和 css 文件
- 如何将 JavaScript 和 CSS 文件添加到 MagentoModule