Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在HTML对象标记中写入数据_Javascript_Html_Dom - Fatal编程技术网

Javascript 在HTML对象标记中写入数据

Javascript 在HTML对象标记中写入数据,javascript,html,dom,Javascript,Html,Dom,出于某种原因,我想用with object标记替换项目中的iframe iframe的工作代码为: var iframeDoc = document.getElementById(id).contentWindow.document; var html = "html string code "//html page source code; iframeDoc.write(html); iframeDoc.close(); 有人能帮我用object替换上面的代码吗 var iframe=do

出于某种原因,我想用with object标记替换项目中的iframe

iframe的工作代码为:

var iframeDoc = document.getElementById(id).contentWindow.document;
var html = "html string code "//html page source code;
iframeDoc.write(html);
iframeDoc.close();
有人能帮我用object替换上面的代码吗

var iframe=document.getElementById("youriframe");//get the iframe
iframe.parentNode.insertBefore(obj=document.createElement("object"),iframe);//insert the obj at the iframes position
iframe.parentNode.removeChild(iframe);//remove iframe
obj.innerHTML="test";//work with the obj

我认为代码是自我解释的…

出于某种原因,我想用with object标记替换项目中的iframe-这是什么原因?这几乎总是个坏主意。iFrame在处理HTML时的行为可以更好地理解。这些代码是无效的。是HTML,其余是javascript。javascript代码中的HTML是不允许的,尽管情况正好相反。@DonaldDuck-在John Slegers重新格式化之前它是有效的-尽管它确实引发了语法错误,但它不起作用。即使没有语法错误,问题也不是只提到使用对象三次而不使用divall@Quentin:哦,对不起,修好了