重新加载页面? [英] Reload page?

查看:58
本文介绍了重新加载页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Javascript页面,需要动态更改,具体取决于用户

输入。整个页面都写在document.write()输出上。


我还是Javascript的新手并遇到页面重新加载的问题。当用户

按下我页面上的按钮时,大多数功能应该清除页面并使用我的wholepage()函数将其重新绘制为
。经过几次重绘后,该页面出现了一些

错误。我是应该清除页面中的div还是wot?


伪代码在这里:


< html> < head>

....

< SCRIPT LANGUAGE =" JavaScript">

....

[很多代码&功能包括wholepage()]

....

function wholepage(){

document.write("< body bgcolor = \" #CCCCCC \">");

document.write("< div id = \" Layer1 \" style = \" position:absolute;");

.... [大量代码]

document.write("< / div>< / body>" ;);

返回true;}

....


函数updateit(){

wholepage();

返回true;}


< / SCRIPT>

< / HEAD>


< SCRIPT LANGUAGE =" JavaScript">

整页()

< / SCRIPT>


< / html>

I have a Javascript page which needs to be dynamically changed depending on user
input. The whole page is written on document.write() output.

I am still new to Javascript and run into problems with page reload. When user
presses a button on my page most functions should clear the page and repaint it
using my wholepage() function. After a couple of repaint the page goes into some
error. Am I supposed to clear the div''s in the page or wot?

The pseudo code is here:

<html> <head>
....
<SCRIPT LANGUAGE="JavaScript">
....
[lots of code & functions including wholepage()]
....
function wholepage() {
document.write("<body bgcolor=\"#CCCCCC\">");
document.write("<div id=\"Layer1\" style=\"position:absolute;");
....[lots of code]
document.write("</div> </body>");
return true;}
....

function updateit() {
wholepage();
return true;}

</SCRIPT>
</HEAD>

<SCRIPT LANGUAGE="JavaScript">
wholepage()
</SCRIPT>

</html>

推荐答案

joeaécrit:
joe a écrit :
我有一个Javascript页面需要根据用户输入动态更改。整个页面都写在document.write()输出上。

我还是Javascript的新手并遇到页面重新加载的问题。当用户按下我页面上的按钮时,大多数功能应该清除页面并使用我的wholepage()函数重新绘制它。经过几次重绘后,页面出现了一些错误。我应该清除页面中的div或者wot吗?

伪代码在这里:

< html> < head>
...
< SCRIPT LANGUAGE =" JavaScript">
...
[很多代码&功能包括整页()]
...
功能整页(){
I have a Javascript page which needs to be dynamically changed depending on user
input. The whole page is written on document.write() output.

I am still new to Javascript and run into problems with page reload. When user
presses a button on my page most functions should clear the page and repaint it
using my wholepage() function. After a couple of repaint the page goes into some
error. Am I supposed to clear the div''s in the page or wot?

The pseudo code is here:

<html> <head>
...
<SCRIPT LANGUAGE="JavaScript">
...
[lots of code & functions including wholepage()]
...
function wholepage() {




更喜欢这样的东西:


var txt ='''';

txt + =''< body bgcolor =" #CCCCCC">'';

txt + =''< div id =" Layer1" style =" position:absolute;'';


等等


txt + =''< \ / div> < \ / body>< \ / html>'';


然后


with(document){open() ;写(txt);关闭();}

}

-

Stephane Moriaux等儿子[moins] vieux Mac


ASM< st ********************* @ wanadoo.fr.invalid>写道:
ASM <st*********************@wanadoo.fr.invalid> wrote:
joeaécrit:
joe a écrit :
我有一个Javascript页面,需要根据用户的输入动态更改。整个页面都写在document.write()输出上。

我还是Javascript的新手并遇到页面重新加载的问题。当用户按下我页面上的按钮时,大多数功能应该清除页面并使用我的wholepage()函数重新绘制它。经过几次重绘后,页面出现了一些错误。我应该清除页面中的div或者wot吗?

伪代码在这里:

< html> < head>
...
< SCRIPT LANGUAGE =" JavaScript">
...
[很多代码&功能包括整页()]
...
功能整页(){
I have a Javascript page which needs to be dynamically changed depending on user
input. The whole page is written on document.write() output.

I am still new to Javascript and run into problems with page reload. When user
presses a button on my page most functions should clear the page and repaint it
using my wholepage() function. After a couple of repaint the page goes into some
error. Am I supposed to clear the div''s in the page or wot?

The pseudo code is here:

<html> <head>
...
<SCRIPT LANGUAGE="JavaScript">
...
[lots of code & functions including wholepage()]
...
function wholepage() {



喜欢这样的东西:

var txt =' ''';
txt + =''< body bgcolor =" #CCCCC">'';
txt + =''< div id =" Layer1" style =" position:absolute;'';

等等

txt + =''< \ / div>< \ / body>< ; \ / html>'';



with(document){open(); write(txt); close();}
}



prefer something like :

var txt = '''';
txt += ''<body bgcolor="#CCCCCC">'';
txt += ''<div id="Layer1" style="position:absolute;'';

and so on

txt += ''<\/div><\/body><\/html>'';

then

with(document){open();write(txt);close();}
}




我正在做什么但是使用document.write()。

close()做什么?



That what I''m doing but with document.write().
What does the close() do?


joe写道:
我有一个Javascript页面,需要根据用户的输入动态更改。整个页面写在document.write()输出上。


这似乎不是一个好主意。你应该修改需要更改的位

,而不是重写整个页面。


我还是Javascript的新手,遇到了问题页面重新加载。当用户按下我页面上的按钮时,大多数功能应该清除页面并使用我的wholepage()函数重新绘制它。经过几次重绘后,页面出现了一些错误。我应该清除页面中的div还是wot?


页面加载完成后调用document.write()将导致

调用document.open(),这将清除整个页面内容。

在某些浏览器中,除了当前正在执行的脚本之外的所有脚本都会立即从内存中删除,而在其他浏览器中它们会持续到新的

页面已写完,但随后便消失了。


清除div的是没有意义的。


伪代码在这里:

< html> < head>
...
< SCRIPT LANGUAGE =" JavaScript">


多年前语言属性已被弃用,类型是必需的。


...
[很多代码&功能包括wholepage()]
...
函数wholepage(){
document.write(" body bgcolor = \"#CCCCCC \">" );


当您调用wholepage()时,上述语句将清除当前文档的整个

内容。看来你没有写一个新的

title元素,所以你现在有了无效的HTML。


你的HTML使用了弃用的属性,你应该看看更新为

HTML 4 - 版本4.01于1999年成为推荐。


document.write("< div id = \" Layer1 \" style = \" position:absolute;");
... [很多代码]


大概是''很多代码' '包括将所有脚本元素

重新写入文档。

document.write("< / div>< / body>");


你应该总是用:


document.close();


否则一些浏览器将永远等待你这样做。


返回true;}
I have a Javascript page which needs to be dynamically changed depending on user
input. The whole page is written on document.write() output.
That does not seem like a good idea. You should just modify the bits
that need to change, not re-write the entire page.

I am still new to Javascript and run into problems with page reload. When user
presses a button on my page most functions should clear the page and repaint it
using my wholepage() function. After a couple of repaint the page goes into some
error. Am I supposed to clear the div''s in the page or wot?
Calling document.write() after the page has finished loading will result
in a call to document.open(), which will clear the entire page content.
In some browsers, all script other than the one currently executing are
removed from memory immediately, in others they persist until the new
page is written but then are gone.

"clear the div''s" is meaningless.

The pseudo code is here:

<html> <head>
...
<SCRIPT LANGUAGE="JavaScript">
The language attribute was deprecated many years ago, type is required.

...
[lots of code & functions including wholepage()]
...
function wholepage() {
document.write("<body bgcolor=\"#CCCCCC\">");
When you call wholepage(), the above statement will clear the entire
content of the current document. It appears that you don''t write a new
title element, so you now have invalid HTML.

Your HTML uses deprecated attributes, you should look at updating to
HTML 4 - version 4.01 became a recommendation in 1999.

document.write("<div id=\"Layer1\" style=\"position:absolute;");
...[lots of code]
Presumably that ''lots of code'' includes writing all the script elements
back into the document too.
document.write("</div> </body>");
You should always finish with:

document.close();

otherwise some browsers will wait forever for you to do so.

return true;}




它返回的是什么?


[...]

-

Rob

小组常见问题:< URL: http://www.jibbering.com/faq/>



What does it return true to?

[...]
--
Rob
Group FAQ: <URL:http://www.jibbering.com/faq/>


这篇关于重新加载页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆