
添加数据 :
数据显示:
ClassModel.js源码 ::
ClassModel =
{
create : function()
{
return function()
{
this.construct.apply(this, arguments);
}
}
}
Extend = function(desc, src)
{
for(var c in src)
{
desc[c] = src[c];
}
return desc;
}
Object.prototype.extend = function(src)
{
return Extend.apply(this, [this, src]);
}
addData.js源码::
var insert = ClassModel.create();
var doc = new ActiveXObject("Msxml2.DOMDocument.3.0");
doc.load("books.xml");
var books;
insert.prototype =
{
construct : function(config)
{
this.id = config.id;
this.name = config.name;
this.author = config.author;
this.price = config.price;
this.publisher = config.publisher;
this.count = config.count;
this.insertData();
},
insertData : function()
{
var book = doc.createElement("book");
book.setAttribute("id", this.id);
var name = doc.createElement("name");
var nameValue = doc.createTextNode(this.name);
name.appendChild(nameValue);
book.appendChild(name);
var author = doc.createElement("author");
var authorValue = doc.createTextNode(this.author);
author.appendChild(authorValue);
book.appendChild(author);
var price = doc.createElement("price");
var priceValue = doc.createTextNode(this.price);
price.appendChild(priceValue);
book.appendChild(price);
var count = doc.createElement("count");
var countValue = doc.createTextNode(this.count);
count.appendChild(countValue);
book.appendChild(count);
var publisher = doc.createElement("publisher");
var publisherValue = doc.createTextNode(this.publisher);
publisher.appendChild(publisherValue);
book.appendChild(publisher);
if(doc.documentElement == null)
{
books = doc.createElement("books");
books.appendChild(book);
doc.appendChild(books);
}
else
{
books = doc.documentElement;
books.appendChild(book);
}
doc.save("books.xml");
}
}
window.js源码::
var windows = ClassModel.create();
windows.prototype =
{
construct : function(jsonObject)
{
this.title = jsonObject.title;
this.width = jsonObject.width;
this.height = jsonObject.height;
this.titleColor = jsonObject.titleColor;
this.backgroundColor = jsonObject.backgroundColor;
this.LwHeight = (document.body.clientHeight - this.width) / 2; //让div在屏幕的中间
this.LwWidth = (document.body.clientWidth - this.height) / 2; //让div在屏幕的中间
this.content = jsonObject.content;
var loginWindow = this.createLoginBody();
var title = this.createLoginTitle();
loginWindow.appendChild(title);
var cont = this.createContent();
loginWindow.appendChild(cont);
document.body.appendChild(loginWindow);
},
createLoginBody: function() //创建登陆框, 即整个框
{
var loginWindow = document.createElement("div");
loginWindow.id = "dialog";
with(loginWindow.style)
{
border = "1px solid white";
position = "absolute";
width = this.width + "px";
height = this.height + "px";
top = this.LwHeight + "px";
left = this.LwWidth + "px";
backgroundColor = this.backgroundColor;
}
return loginWindow;
},
createLoginTitle:function() //创建 标题 即效果图的黑色标题
{
var title = document.createElement("div");
var table = document.createElement("table");
var tbody = document.createElement("tbody");
var tr = document.createElement("tr");
var td_1 = document.createElement("td");
var td_2 = document.createElement("td");
var close = document.createElement("a");
close.onclick = function()
{
document.body.removeChild(title.parentNode);
}
close.innerHTML = "X";
td_1.innerHTML = this.title;
with(title.style)
{
width = "100%";
height = this.height / 10 + "px";
backgroundColor = this.titleColor;
}
with(table.style)
{
color = "white";
fontSize = "12pt";
width = "100%";
backgroundColor = this.titleColor;
color = "red";
}
td_2.style.textAlign = "right";
td_2.appendChild(close);
tr.appendChild(td_1);
tr.appendChild(td_2);
tbody.appendChild(tr);
table.appendChild(tbody);
title.appendChild(table);
return title;
},
createContent : function()
{
var div = document.createElement("div");
if(typeof(this.content) == 'string')
{
div.innerHTML = this.content;
}else
{
div.appendChild(this.content);
}
with(div.style)
{
paddingLeft = "80px";
paddingTop = "50px";
float = "left";
width = "100%";
}
return div;
}
}
book_infor.js源码::
var doc = new ActiveXObject("Msxml2.DOMDocument.3.0");
doc.load("books.xml");
var query = ClassModel.create();
var v = 0;
query.prototype =
{
construct : function()
{
this.bookInfor();
},
bookInfor : function()
{
var div = document.createElement("div");
var root = doc.documentElement;
if(root == null)
{
div.innerHTML = "no data";
document.body.appendChild(div);
}else
{
with(div.style)
{
marginLeft = "200px";
overflow = "auto";
border = "0px solid white";
width = "605px";
}
var table = document.createElement("table");
table.cellSpacing = "0";
with(table.style)
{
fontSize = "12pt";
color = "white";
border = "0px";
width = "600px";
}
var tbody = document.createElement("tbody");
var trHead = document.createElement("tr");
with(trHead.style)
{
height = "20px";
backgroundColor = "Transparent";
}
var tname = document.createElement("td");
var tauthor = document.createElement("td");
var tprice = document.createElement("td");
var tCount = document.createElement("td");
var tpublisher = document.createElement("td");
tname.innerHTML = "名称";
tauthor.innerHTML = "作者";
tprice.innerHTML = "价格";
tCount.innerHTML = "库存";
tpublisher.innerHTML = "出版社";
tname.style.borderBottom = "1px solid";
tauthor.style.borderBottom = "1px solid";
tprice.style.borderBottom = "1px solid";
tCount.style.borderBottom = "1px solid";
tpublisher.style.borderBottom = "1px solid";
tname.style.width = "20%";
tauthor.style.width = "20%";
tprice.style.width = "20%";
tCount.style.width = "20%";
tpublisher.style.width = "20%";
trHead.appendChild(tname);
trHead.appendChild(tauthor);
trHead.appendChild(tprice);
trHead.appendChild(tCount);
trHead.appendChild(tpublisher);
tbody.appendChild(trHead);
for(var c = 0; c {
var roots = root.getElementsByTagName("book")[c];
var id = roots.getAttribute("id");
var name = roots.getElementsByTagName("name")[0].childNodes[0].nodeValue;
var author = roots.getElementsByTagName("author")[0].childNodes[0].nodeValue;
var price = roots.getElementsByTagName("price")[0].childNodes[0].nodeValue;
var count = roots.getElementsByTagName("count")[0].childNodes[0].nodeValue;
var publisher = roots.getElementsByTagName("publisher")[0].childNodes[0].nodeValue;
var tr = document.createElement("tr");
with(tr.style)
{
backgroundColor = "Transparent";
}
var tdName = document.createElement("td");
var tdAuthor = document.createElement("td");
var tdPrice = document.createElement("td");
var tdCount = document.createElement("td");
var tdPublisher = document.createElement("td");
tdName.innerHTML = name;
tdAuthor.innerHTML = author;
tdPrice.innerHTML = price;
tdCount.innerHTML = count;
tdPublisher.innerHTML = publisher;
tdName.id = "tdName" + c;
tdAuthor.id = "tdAuthor" + c;
tdPrice.id = "tdPrice" + c;
tdCount.id = "tdCount" + c;
tdPublisher.id = "tdPublisher" + c;
tr.appendChild(tdName);
tr.appendChild(tdAuthor);
tr.appendChild(tdPrice);
tr.appendChild(tdCount);
tr.appendChild(tdPublisher);
tbody.appendChild(tr);
tdName.onmouseover = function(){
document.body.style.cursor= "pointer";
document.getElementById(this.id).style.backgroundColor = "darkred";
}
tdName.onmouseout = function(){
document.body.style.cursor= "";
document.getElementById(this.id).style.backgroundColor = "";
}
tdAuthor.onmouseover = function(){
document.body.style.cursor= "pointer";
document.getElementById(this.id).style.backgroundColor = "darkred";
}
tdAuthor.onmouseout = function(){
document.body.style.cursor= "";
document.getElementById(this.id).style.backgroundColor = "";
}
tdPrice.onmouseover = function(){
document.body.style.cursor= "pointer";
document.getElementById(this.id).style.backgroundColor = "darkred";
}
tdPrice.onmouseout = function(){
document.body.style.cursor= "";
document.getElementById(this.id).style.backgroundColor = "";
}
tdCount.onmouseover = function(){
document.body.style.cursor= "pointer";
document.getElementById(this.id).style.backgroundColor = "darkred";
}
tdCount.onmouseout = function(){
document.body.style.cursor= "";
document.getElementById(this.id).style.backgroundColor = "";
}
tdPublisher.onmouseover = function(){
document.body.style.cursor= "pointer";
document.getElementById(this.id).style.backgroundColor = "darkred";
}
tdPublisher.onmouseout = function(){
document.body.style.cursor= "";
document.getElementById(this.id).style.backgroundColor = "";
}
}
table.appendChild(tbody);
div.appendChild(table);
document.body.appendChild(div);
}
}
}

JavaScript的最新趨勢包括TypeScript的崛起、現代框架和庫的流行以及WebAssembly的應用。未來前景涵蓋更強大的類型系統、服務器端JavaScript的發展、人工智能和機器學習的擴展以及物聯網和邊緣計算的潛力。

JavaScript是現代Web開發的基石,它的主要功能包括事件驅動編程、動態內容生成和異步編程。 1)事件驅動編程允許網頁根據用戶操作動態變化。 2)動態內容生成使得頁面內容可以根據條件調整。 3)異步編程確保用戶界面不被阻塞。 JavaScript廣泛應用於網頁交互、單頁面應用和服務器端開發,極大地提升了用戶體驗和跨平台開發的靈活性。

Python更适合数据科学和机器学习,JavaScript更适合前端和全栈开发。1.Python以简洁语法和丰富库生态著称,适用于数据分析和Web开发。2.JavaScript是前端开发核心,Node.js支持服务器端编程,适用于全栈开发。

JavaScript不需要安裝,因為它已內置於現代瀏覽器中。你只需文本編輯器和瀏覽器即可開始使用。 1)在瀏覽器環境中,通過標籤嵌入HTML文件中運行。 2)在Node.js環境中,下載並安裝Node.js後,通過命令行運行JavaScript文件。

如何在Quartz中提前發送任務通知在使用Quartz定時器進行任務調度時,任務的執行時間是由cron表達式設定的。現�...

在JavaScript中如何獲取原型鏈上函數的參數在JavaScript編程中,理解和操作原型鏈上的函數參數是常見且重要的任�...

在微信小程序web-view中使用Vue.js動態style位移失效的原因分析在使用Vue.js...

在Tampermonkey中如何對多個鏈接進行並發GET請求並依次判斷返回結果?在Tampermonkey腳本中,我們經常需要對多個鏈...


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

SublimeText3 Linux新版
SublimeText3 Linux最新版

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3漢化版
中文版,非常好用

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。