} 再次起作用() {var /> var i = 0; for(i = 0;我小于5; i ++) { document.write(this.questions [i] +"< br>"); } } < / SCRIPT> < / HEAD> < BODY> < input type =" button" value =" see questions" onclick =" display_questions()" /> < / BODY> < / html> } function again() { var i=0; for (i = 0; i<5; i++) { document.write(this.questions[i] + "<br>"); } } </SCRIPT> </HEAD> <BODY> <input type="button" value="see questions" onclick="display_questions()" /> </BODY> </html> Peroli, 你能告诉我你的意思吗?通过第二个选项?! 干杯 Geoff Peroli, Could you please give me an idea what you mean by the second option?! Cheers Geoff 您似乎正在尝试document.write一个XHTML元素(结束 " />"看起来像XHTML),但是document.write通常不会为解析的XHTML页面工作 。 无论如何,当单击此按钮时,再次调用函数。 函数再次() {var /> var i = 0; for(i = 0; i< 5; i ++) 更短一点: for(var i = 0; i< 5; i ++) { document.write(this.questions [i] +"< br>"); 通过用户点击按钮调用。这表明 页面在调用时已经完成加载。在完成加载后在页面上执行document.write 将删除整个页面,并且 将其替换为所写的内容。 另外,this operator是指全局对象(又名window), ,它没有问题。属性。 < input type =" button" value =" see questions" onclick =" display_questions()" /> You seem to be trying to document.write an XHTML element (the closing"/>" looks like XHTML), but document.write generally doesn''t workfor XHTML pages parsed as such. Anyway, when this button is clicked, the again function is called. function again() { var i=0; for (i = 0; i<5; i++)A little shorter:for (var i = 0; i < 5; i++) { document.write(this.questions[i] + "<br>");This is called through a user click on a button. That suggests that thepage is already done loading when this is called. Doing "document.write"on a page after it has finished loading will erase the entire page, andreplace it with what is written. Also, the "this" operator refers to the global object (aka "window"),which doesn''t have a "questions" property. <input type="button" value="see questions" onclick="display_questions()" /> 这会调用第一个函数,它也会删除页面。 通常,document.write是不是向页面添加内容的方式 已经加载。有不同的方法可以做到这一点,通过W3C DOM或使用专有的innerHTML来实现。物业。 < URL:http://jibbering.com/faq/#FAQ4_15> / L - - Lasse Reichstein Nielsen - lr*@hotpop.com DHTML死亡颜色: < URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> ''没有判断的信仰只会降低精神神圣。'' And this calls the first function, which also erases the page. Generally, document.write is not the way to add content to a pagethat is already loaded. There are different ways to do that, eitherthrough the W3C DOM or using the proprietary "innerHTML" property.<URL:http://jibbering.com/faq/#FAQ4_15> /L--Lasse Reichstein Nielsen - lr*@hotpop.comDHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>''Faith without judgement merely degrades the spirit divine.'' 这篇关于简单的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-23 06:03