document.write和缓冲区数据 [英] document.write and buffer data
问题描述
嗨
这是一个非常有趣的问题。我甚至无法在谷歌上找到任何有关它的信息。
我认为最好的解释方式就是这个简单的例子:
< html>
< body>
< script language =" JavaScript" type =" text / javascript"
src =" write.js">< / script>
< / body>
< / html>
write.js:
document.write(" start< br /> \ n");
document.write("<" +" script language =''JavaScript''
type =''text / javascript''src =''test .js''><" +" / script>");
document.write(" end< br /> \ n");
和test.js:
document.write(''middle< br />'');
预期输出是:
开始
中间
结束
但实际输出是:
start
end
middle
此输出必须在write.js内生成文件,我必须
有时使用一些像这样的外部文件test.js。
我正试图找到一个强制浏览器输出的解决方案所有内容
来自test.js之前的结束。
我发现只有这个信息:
http://www.web-developer-india.com/w...t/ refp_95.html
我发现放置HTML标签(不带JavaScript)强制使用
浏览器来输出缓冲区。但不幸的是,我无法在write.js文件中输出任何
HTML标签。
是否可以强制浏览器在之前呈现内容;结束"
document.write?
Hi
It''s very interesting problem. I couldn''t even find any inforamtion
about it on the google.
I think that the best way of explain will be this simple example:
<html>
<body>
<script language="JavaScript" type="text/javascript"
src="write.js"></script>
</body>
</html>
write.js:
document.write("start<br />\n");
document.write("<" + "script language=''JavaScript''
type=''text/javascript'' src=''test.js''><" + "/script>");
document.write("end<br />\n");
and test.js:
document.write(''middle <br />'');
The expected output is:
start
middle
end
but the real output is:
start
end
middle
This output has to be generated inside "write.js" file and I have to
use sometimes some external files like this "test.js".
I''m trying to find a solution to force a browser to output everything
from test.js before the "end".
I found only this info:
http://www.web-developer-india.com/w...t/refp_95.html
where I found that placing HTML tag (without JavaScript) force a
browser to output the buffer. But unfortuanetly I couldn''t output any
HTML tag inside write.js file.
Is it possible to force a browser to render the content before "end"
document.write?
推荐答案
" Radek Maciaszek" < RA ************* @ gmail.com>在消息中写道
news:39 ************************** @ posting.google.c om ...
"Radek Maciaszek" <ra*************@gmail.com> wrote in message
news:39**************************@posting.google.c om...
嗨
这是一个非常有趣的问题。我甚至无法在谷歌上找到关于它的任何信息。
我认为最好的解释方式就是这个简单的例子:
< html>
< body>
< script language =" JavaScript" type =" text / javascript"
src =" write.js">< / script>
< / body>
< / html>
write.js:
document.write(" start< br /> \ n");
document.write("<" +" script language =' 'JavaScript''
type =''text / javascript''src =''test.js''><" +" / script>");
document.write( " end< br /> \ n");
和test.js:
document.write(''middle< br />'');
预期输出为:
开始
结束
但实际输出是:
start
end
中间
此输出必须在write.js内生成。文件,我必须有时使用一些像这样的外部文件test.js。
我正在试图找到一个解决方案来强制浏览器从测试中输出所有内容。 js在结束之前。
我发现只有这个信息:
http://www.web-developer-india.com/w...t/refp_95.html
在哪里我发现放置HTML标记(不含JavaScript)强制
浏览器输出缓冲区。但不幸的是,我无法在write.js文件中输出任何
HTML标签。
是否可以强制浏览器在结束之前呈现内容
文档.write?
Hi
It''s very interesting problem. I couldn''t even find any inforamtion
about it on the google.
I think that the best way of explain will be this simple example:
<html>
<body>
<script language="JavaScript" type="text/javascript"
src="write.js"></script>
</body>
</html>
write.js:
document.write("start<br />\n");
document.write("<" + "script language=''JavaScript''
type=''text/javascript'' src=''test.js''><" + "/script>");
document.write("end<br />\n");
and test.js:
document.write(''middle <br />'');
The expected output is:
start
middle
end
but the real output is:
start
end
middle
This output has to be generated inside "write.js" file and I have to
use sometimes some external files like this "test.js".
I''m trying to find a solution to force a browser to output everything
from test.js before the "end".
I found only this info:
http://www.web-developer-india.com/w...t/refp_95.html
where I found that placing HTML tag (without JavaScript) force a
browser to output the buffer. But unfortuanetly I couldn''t output any
HTML tag inside write.js file.
Is it possible to force a browser to render the content before "end"
document.write?
ASP是一个选项吗?
如果是这样,那么你可以使用FileSystemObject来合并包含。
Is ASP an option?
If so then you could use the FileSystemObject to merge the includes.
" McKirahan" <氖** @ McKirahan.com>在消息新闻中写道:< Rr ******************** @ comcast.com> ...
"McKirahan" <Ne**@McKirahan.com> wrote in message news:<Rr********************@comcast.com>...
是ASP一个选项?
如果是这样,那么你可以使用FileSystemObject来合并包含。
Is ASP an option?
If so then you could use the FileSystemObject to merge the includes.
我在服务器上安装了PHP,但不幸的是我无法在这种情况下使用它
因为HTML,write.js和test.js在三个不同的服务器上。所以
例如我可以包含write.js通过PHP但我不知道是否
write.js只返回一个document.write或将尝试包括
" test.js"或任何其他js文件。而且我无法改变这些
的要求...所以唯一的解决方案(IMO)就是强制浏览器在结束之前完成所有内容的渲染。标签,但在IE中的纯JavaScript和Mozilla中都没有这样的可能性。我希望我错了
错误..
I have PHP on server but unfortunately I couldn''t use it in this case
because HTML, write.js and test.js are on three different servers. So
for example I could include "write.js" by PHP but I don''t know if
write.js return just a "document.write" or will try to include
"test.js" or any other js file. And I couldn''t change these
requirements... So the only solution (IMO) is to force a browser to
finish rendering everything before the "end" tag but there is no such
possibility in pure JavaScript in IE nor in Mozilla. I hope I am
wrong..
借助Ultimater帮助我找到了解决这个问题的方法。只需要用火来打击
a fire。
document.write("< script src =''start.js''> \< ; / script>");
document.write("< script src =''test.js''> \< / script>");
document.write("< script src =''end.js''> \< / script>");
这里是链接:
http://www.webdeveloper .com / forum / sh ... ad.php?t = 61386
欢呼
Radek
With Ultimater help I''ve found a solution to this problem. Just fight
a fire with a fire.
document.write("<script src=''start.js''>\</script>");
document.write("<script src=''test.js''>\</script>");
document.write("<script src=''end.js''>\</script>");
here is the link:
http://www.webdeveloper.com/forum/sh...ad.php?t=61386
cheers
Radek
这篇关于document.write和缓冲区数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!