怎么输出成HTML代码...
我想输出成这样..
<SCRIPT>
var widths=384;
var heights=265;
var counts=4;
img1=new Image();img1.src= '/imagelist/07/07/4219635_8980.jpg ';
img2=new Image();img2.src= '/imagelist/07/07/4218572_9143.jpg ';
img3=new Image();img3.src= '/imagelist/07/07/4218055_8472.jpg ';
img4=new Image();img4.src= '/imagelist/07/07/4217763_5661.jpg ';
url1=new Image();url1.src= 'http://pic.yesky.com/pic/tuijian/ ';
url2=new Image();url2.src= 'http://pic.yesky.com/pic/tuijian/ ';
url3=new Image();url3.src= 'http://pic.yesky.com/pic/tuijian/ ';
url4=new Image();url4.src= 'http://pic.yesky.com/pic/tuijian/ ';
</SCRIPT>
查看源代码的时候就是上边那样....
但我这样写:
<SCRIPT>
var widths=313;
var heights=231;
var counts=5;
for(i=1;i <=5;i++){
document.write( "img[ " + i + "]=new Image();img[ " + i + "].src= '8888.gif '; ");
document.write( "url[ " + i + "]=new Image();url[ " + i + "].src= 'www.wwww.com '; ");
}
</SCRIPT>
就直接输出到页面了 ...
请问怎么能实现???
------解决方案--------------------不能输出
只能用eval()函数
eval( "img[ " + i + "]=new Image();img[ " + i + "].src= '8888.gif '; ");
eval( "url[ " + i + "]=new Image();url[ " + i + "].src= 'www.wwww.com '; ");
eval能直接执行指定的JS代码