相关疑难解决方法(0)

Javascript - 打破字符串文字......为什么?

对不起,问题标题太模糊了,但是我正在查看Job posts board转换跟踪软件的一些代码,并且第一次遇到这个问题.

    document.write('<i' + 'mg height="1" ' +
         'width="1" border="0" ' +
         'src="' + url + '&ifr' + 'ame=0" />');
    document.write('</ifr' + 'ame>');
Run Code Online (Sandbox Code Playgroud)

他们为什么以这种方式分解字符串文字?特别'</ifr'+'ame>'

javascript

7
推荐指数
2
解决办法
167
查看次数

JavaScript如何创建包含更多JavaScript的新页面?

我正在使用JS打开新页面并将HTML代码写入其中,但是当我尝试使用document.write()函数在新页面内编写JS时,它无效.显然主JS一看到</script>它就会关闭将打开的新页面的JS.

有没有解决的办法?

var opened = window.open("");
opened.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
opened.document.write("<html lang=\"en-US\" xml:lang=\"en-US\" xmlns=\"http://www.w3.org/1999/xhtml\">");
opened.document.write("<head><title>Print Copy</title></head>");
opened.document.write("<body>");
opened.document.write("<script type=\"text/javascript\">");
opened.document.write("</script>");
opened.document.write("<p>test</p></body></html>");
Run Code Online (Sandbox Code Playgroud)

html javascript function document.write

2
推荐指数
2
解决办法
264
查看次数

标签 统计

javascript ×2

document.write ×1

function ×1

html ×1