Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.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
在html页面中显示javascript代码_Javascript_Html_Internet Explorer 6 - Fatal编程技术网

在html页面中显示javascript代码

在html页面中显示javascript代码,javascript,html,internet-explorer-6,Javascript,Html,Internet Explorer 6,在IE怪癖模式下,我想使用以下代码在html页面上显示一些javascript函数: document.write('<pre>' + someFunction + '</pre>'); 如何使其显示函数的完整源代码?将替换为将替换为您可以使用它们的html Rxpression,而不是使用那些“”符号 例如代替 这会解决你的问题。试试这个。不要使用“”符号,你可以使用它们的html Rxpression 例如代替 这会解决你的问题。试试这个。使用.replace(),

在IE怪癖模式下,我想使用以下代码在html页面上显示一些javascript函数:

document.write('<pre>' + someFunction + '</pre>');
如何使其显示函数的完整源代码?

替换为

替换为

您可以使用它们的html Rxpression,而不是使用那些“”符号

例如
代替<和
代替>

这会解决你的问题。试试这个。

不要使用“”符号,你可以使用它们的html Rxpression

例如
代替<和
代替>

这会解决你的问题。试试这个。

使用.replace(),例如

函数foo(i){ 如果(i<10){ 警报(“酒吧”); } } document.write(“+foo.toString().replace(“Use.replace(),例如

函数foo(i){ 如果(i<10){ 警报(“酒吧”); } } document.write(“+foo.toString().replace(”
function a(j){
   var i = 0;
   if(i<j){
       alert(j + ' is greater than zero');
   }
}
function a(j){
       var i = 0;
       if(i
function foo(i) {
  if (i < 10) {
    alert("bar");
  }
}
document.write("<pre>"+foo.toString().replace("<","&lt;")+"</pre>");
function foo(i) {
    if (i < 10) {
        alert("bar");
    }
}