写一块html [英] writing slabs of html

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

问题描述

hi ppl


我已经在html文件中创建了一个javascript组件,我希望能够在其他页面上使用这个
,所以我要把它放到一个js文件中。

的事情是,90%html和10%java的组件。那么我如何打印出一整块html而不必做一个可怕的批次

document.write?无法弄清楚其他组件是如何做到的。

欢呼

dave

解决方案
<毫安********** @ hotmail.com>在消息中写道

news:10 ********************** @ h37g2000oda.googlegr oups.com ...

嗨ppl

我已经在html文件中创建了一个javascript组件,我希望能够在其他页面上使用它,所以我要去把它放到一个js文件中。
事情是,90%html和10%java中的组件。那么我如何打印出一整页html而不必做一大堆可怕的
document.write?无法弄清楚其他组件是如何做到的。
欢呼
dave



将Java放在一个单独的.js文件中。


另外,为避免大量的document.write语句,

使用一个数组;例如,尝试类似的事情:


var a = new Array();

a [i ++] =" 1";

a [i ++] =" 2";

a [i ++] =" 3";

for(i = 0; i< a.length; i ++) {

document.write a [i];

}


McKirahan写道:

< ma ********** @ hotmail.com>在消息中写道
新闻:10 ********************** @ h37g2000oda.googlegr oups.com ......

嗨ppl

我已经在html文件中创建了一个javascript组件,我希望能够在其他页面上使用它,所以我要去把它放到一个js文件中。
事情是,90%html和10%java中的组件。那么我如何打印出一整页html而不必做一大堆可怕的
document.write?无法弄清楚其他组件是如何做到的。
欢呼
dave

将Java放在一个单独的.js文件中。




< pedant>

Java!= Javascript

< / pedant>


另外,到避免使用大量的document.write语句,
使用数组;例如,尝试以下方法:

var a = new Array();
a [i ++] =" 1" ;;
a [i ++] =" 2" ;
a [i ++] =" 3";
for(i = 0; i< a.length; i ++){
document.write a [i];
}




这并没有避免大量的document.write语句,它只是避免了作者必须输入它们的
。如果数组中有10,000个项目,那么

则会调用document.write 10,000次。它更有效,更快,使用串联然后一个document.write:


var i = 0;

var myVar ="" ;;

var a = new Array();

a [i ++] =" 1";

a [i ++] =" 2";

a [i ++] =" 3";

for(i = 0; i< a.length; i ++){

myVar + = a [i];

}

document.write(myVar);


-

兰迪

comp.lang.javascript常见问题 - http://jibbering.com/faq


" Randy Webb" <您好************ @ aol.com>在消息中写道

新闻:yY ******************** @ comcast.com ...

McKirahan写道:

< ma ********** @ hotmail.com>在消息中写道
新闻:10 ********************** @ h37g2000oda.googlegr oups.com ......

嗨ppl

我已经在html文件中创建了一个javascript组件,我希望能够在其他页面上使用它,所以我要去把它放到一个js文件中。
事情是,90%html和10%java中的组件。那么我如何打印出一整页html而不必做一大堆可怕的
document.write?无法弄清楚其他组件是如何做到的。
欢呼
dave



将Java放在一个单独的.js文件中。



< pedant>
Java!= Javascript
< / pedant>

另外,要避免众多文档。写声明,使用数组;例如,尝试以下方法:

var a = new Array();
a [i ++] =" 1" ;;
a [i ++] =" 2" ;
a [i ++] =" 3";
for(i = 0; i< a.length; i ++){
document.write a [i];
}



这并没有避免大量的document.write语句,它只是避免了作者必须输入它们。如果数组中有10,000个项目,则
然后将document.write调用10,000次。它更有效,更快,使用连接然后一个document.write:

var i = 0;
var myVar ="";
var a = new Array();
a [i ++] =" 1" ;;
a [i ++] =" 2";
a [i ++] =" 3" ;;
for(i = 0; i< a.length; i ++){
myVar + = a [i];
}
document.write(myVar); <兰迪
comp.lang.javascript常见问题 -
-
> http://jibbering.com/faq




我确实说过类似的东西 :)


我其实是想说你做了什么。


hi ppl

i''ve made a javascript component in a html file, and i want to be able
to use this on other pages, so i''m going to put it into a js file.
thing is, the component in 90% html and 10% java. so how do i print out
a whole slab of html without having to do a hideous batch of
document.write? couldn''t figure out how other components did it.
cheers
dave

解决方案

<ma**********@hotmail.com> wrote in message
news:10**********************@h37g2000oda.googlegr oups.com...

hi ppl

i''ve made a javascript component in a html file, and i want to be able
to use this on other pages, so i''m going to put it into a js file.
thing is, the component in 90% html and 10% java. so how do i print out
a whole slab of html without having to do a hideous batch of
document.write? couldn''t figure out how other components did it.
cheers
dave


Put the Java in a separate .js file.

Also, to avoid numerous document.write statements,
use an array; for example, try something like:

var a = new Array();
a[i++] = "1";
a[i++] = "2";
a[i++] = "3";
for (i=0; i<a.length; i++) {
document.write a[i];
}


McKirahan wrote:

<ma**********@hotmail.com> wrote in message
news:10**********************@h37g2000oda.googlegr oups.com...

hi ppl

i''ve made a javascript component in a html file, and i want to be able
to use this on other pages, so i''m going to put it into a js file.
thing is, the component in 90% html and 10% java. so how do i print out
a whole slab of html without having to do a hideous batch of
document.write? couldn''t figure out how other components did it.
cheers
dave
Put the Java in a separate .js file.



<pedant>
Java != Javascript
</pedant>

Also, to avoid numerous document.write statements,
use an array; for example, try something like:

var a = new Array();
a[i++] = "1";
a[i++] = "2";
a[i++] = "3";
for (i=0; i<a.length; i++) {
document.write a[i];
}



That doesn''t avoid numerous document.write statements, it just avoids
the author having to type them. If the array has 10,000 items in it,
then the document.write is called 10,000 times. Its a lot more
efficient, and faster, to use concatenation and then one document.write:

var i=0;
var myVar = "";
var a = new Array();
a[i++] = "1";
a[i++] = "2";
a[i++] = "3";
for (i=0; i<a.length; i++) {
myVar += a[i];
}
document.write(myVar);

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq


"Randy Webb" <Hi************@aol.com> wrote in message
news:yY********************@comcast.com...

McKirahan wrote:

<ma**********@hotmail.com> wrote in message
news:10**********************@h37g2000oda.googlegr oups.com...

hi ppl

i''ve made a javascript component in a html file, and i want to be able
to use this on other pages, so i''m going to put it into a js file.
thing is, the component in 90% html and 10% java. so how do i print out
a whole slab of html without having to do a hideous batch of
document.write? couldn''t figure out how other components did it.
cheers
dave



Put the Java in a separate .js file.



<pedant>
Java != Javascript
</pedant>

Also, to avoid numerous document.write statements,
use an array; for example, try something like:

var a = new Array();
a[i++] = "1";
a[i++] = "2";
a[i++] = "3";
for (i=0; i<a.length; i++) {
document.write a[i];
}



That doesn''t avoid numerous document.write statements, it just avoids
the author having to type them. If the array has 10,000 items in it,
then the document.write is called 10,000 times. Its a lot more
efficient, and faster, to use concatenation and then one document.write:

var i=0;
var myVar = "";
var a = new Array();
a[i++] = "1";
a[i++] = "2";
a[i++] = "3";
for (i=0; i<a.length; i++) {
myVar += a[i];
}
document.write(myVar);

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq



Well I did say "something like" :)

I actually meant to say what you did.


这篇关于写一块html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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