Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.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
如何在wordpress post中显示html结果视图_Wordpress - Fatal编程技术网

如何在wordpress post中显示html结果视图

如何在wordpress post中显示html结果视图,wordpress,Wordpress,我想在文本区域显示html代码,然后用户可以点击查看结果 代码: html 身体 P 此文本将显示在您的网页上。 /p !-- 这些注释标记中的文本将不会显示在网页上 -- /身体 /html 查看结果 函数视图() { var result=window.open(“,”,“height=400,left=“+((screen.width)?(screen.width-400)/2:0)+”,top=“+((screen.height)?(screen.height-400)/2:0)+”,

我想在文本区域显示html代码,然后用户可以点击查看结果

代码:

html
身体
P
此文本将显示在您的网页上。
/p
!--
这些注释标记中的文本将不会显示在网页上
--
/身体
/html
查看结果
函数视图()
{
var result=window.open(“,”,“height=400,left=“+((screen.width)?(screen.width-400)/2:0)+”,top=“+((screen.height)?(screen.height-400)/2:0)+”,width=400”);
var tmp=result.document;
write(document.getElementById('html').value);
tmp.close();
返回false;
}

我试着在wordpress post上发布它,但不起作用。

wordpress默认会去掉HTML标记。一个简单的开始方法是使用一个插件,比如将代码粘贴到其中,然后使用一个短代码来运行它。理想情况下,您希望研究构建自己的插件,但作为一种快速修复方法,这将非常适合您:)

默认情况下,WordPress会去掉HTML标记。一个简单的开始方法是使用一个插件,比如将代码粘贴到其中,然后使用一个短代码来运行它。理想情况下,您希望研究构建自己的插件,但作为一个快速解决方案,这将非常适合您:)

没问题,请标记为答案并标记为已解决:)谢谢没有问题,请标记为答案并标记为已解决:)谢谢
<textarea id="html" cols="50" rows="10">&lt;html&gt;
&lt;body&gt;
&lt;p&gt;
This text will appear on your webpage.
&lt;/p&gt; 
&lt;!--
the text within these comment tags will not appear on the web page
--&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea>

<div>
<button onclick="view()">View Results</button>
</div>

<script type="text/javascript">
function view()
{
    var result = window.open("", "", "height=400,left=" + ((screen.width) ? (screen.width-400)/2 : 0) + ",top=" + ((screen.height) ? (screen.height-400)/2 : 0) + ",width=400");

    var tmp = result.document;
    tmp.write(document.getElementById('html').value);
    tmp.close();

    return false;
}
</script>