[英]JavaScript tweak code for loading HTML table instead of picture (PNG)
I have a piece of code which loads an image.我有一段代码可以加载图像。 But my new resources will all be in HTML tables instead of the image of a table.但是我的新资源将全部位于 HTML 表中,而不是表的图像中。 Can you please help me tweak it?你能帮我调整一下吗? I'm wondering whether it's possible.我想知道这是否可能。 So a couple of queries will combine an image name which I have stored as png files.因此,几个查询将组合我存储为 png 文件的图像名称。 But my new source will be.html simple 13 by 13 tables containing some data.但我的新来源将是.html 简单的 13 x 13 表,其中包含一些数据。 This is the only way I can export it from my third party program.这是我可以从我的第三方程序中导出它的唯一方法。 How can I change the function below so that it will load my HTML source instead of the image?如何更改下面的 function 以便它加载我的 HTML 源而不是图像?
setImageSource: function() {
if (isProductionEnvironment) {
document.querySelector('#result-image-1').src = `/xx/xx/images/${imageName}.png`;
} else {
document.querySelector('#result-image-1').src = `https://xx/xx/images/${imageName}.png`;
}
},
Thank you for your effort感谢你的付出
Ok, based on my assumption, instead of load an image, you want to load an.html file;好的,根据我的假设,您不想加载图像,而是要加载 .html 文件; right now you use an img tag with a src value according with the user input something like your code.现在,您根据用户输入的代码使用带有 src 值的 img 标签。 Then now you wanna load html code, for that you can use iframe tag with a src
value or an object tag with a data
value according with the user input.然后现在您要加载 html 代码,为此您可以使用带有src
值的 iframe 标记或带有data
值的 object 标记与用户输入一致。
iframe https://www.w3schools.com/tags/tag_iframe.asp iframe https://www.w3schools.com/tags/tag_iframe.asp
object https://www.w3schools.com/tags/tag_object.asp object https://www.w3schools.com/tags/tag_object.asp
Something like this...像这样的东西...
setIframeSource: function() {
if (isProductionEnvironment) {
document.querySelector('#result-iframe-1').src = `/xx/xx/images/${imageName}.html`;
} else {
document.querySelector('#result-iframe-1').src = `https://xx/xx/images/${imageName}.html`;
}
},
setObjectData: function() {
if (isProductionEnvironment) {
document.querySelector('#result-object-1').data = `/xx/xx/images/${imageName}.html`;
} else {
document.querySelector('#result-object-1').data = `https://xx/xx/images/${imageName}.html`;
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.