JavaScript打印函数myPrint(obj): JavaScript打印页面指定div区域原理:使用window.open()在浏览器打开一个新的页面(window), 使用 window.document.write()将指定div区域的内容写入新窗口文档,document.close()关闭文档,使用window.print()调用打印机打印当前文档. function myPrint(obj){ //打开一个新窗口newWindow var newWindow=window.ope
正三角代码: package BasicType; /** * 封装一个可以根据用户传入值来打印正三角的方法 * @author Administrator */ public class Enme { //n代表打印的层数 public static void print_positive_triangle(int n){ //第一层1个,第二层三个,第三层5个...类比退出第n层就是last个* int last = 2*(n-1)+1; //控制打印多少层 for (int i=0;i<n
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta h
2.0 简单介绍 正則表達式是能够用来查找与给定模式匹配的文本的搜索模式.比如,在上一章中,我们在一个较长的字符串中查找子字符串Cookbook: var testValue = "This is the Cookbook's test string"; var subsValue = "Cookbook"; var iValue = testValue.indexOf(subsValue); //返回值12.即子字符串的索引 这段代码有效.由于我们要查找一个严格的
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Page</title> <script language="javascript" type="text/javascript"> function printDiv(divID) { //Get the HTML of div var divEleme
//js对象打印函数 function writeObj(obj) { var description = ""; for (var i in obj) { var property = obj[i]; description += i + " = " + property + "\n"; } alert(description); }