導航:首頁 > 源碼編譯 > jsnew的源碼

jsnew的源碼

發布時間:2022-08-16 07:20:49

⑴ js讀取遠程網頁源碼

代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>遠程網頁源代碼讀取</title>
<style type="text/css">
/* 頁面字體樣式 */
body, td, input, textarea {
font-family:Arial;
font-size:12px;
}
</style>
<script type="text/javascript">
//用於創建XMLHttpRequest對象
function createXmlHttp() {
//根據window.XMLHttpRequest對象是否存在使用不同的創建方式
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest(); //FireFox、Opera等瀏覽器支持的創建方式
} else {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");//IE瀏覽器支持的創建方式
}
}
//直接通過XMLHttpRequest對象獲取遠程網頁源代碼
function getSource() {
var url = document.getElementById("url").value; //獲取目標地址信息
//地址為空時提示用戶輸入
if (url == "") {
alert("請輸入網頁地址 。");
return;
}
document.getElementById("source").value = "正在載入……"; //提示正在載入
createXmlHttp(); //創建XMLHttpRequest對象
xmlHttp.onreadystatechange = writeSource; //設置回調函數
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
//將遠程網頁源代碼寫入頁面文字區域
function writeSource() {
if (xmlHttp.readyState == 4) {
document.getElementById("source").value = xmlHttp.responseText;
}
}
</script>
</head>
<body>
<h1>遠程網頁源代碼讀取</h1>
<div>
地址:<input type="text" id="url">
<input type="button" onclick="getSource()" value="獲取源碼">
</div>
<textarea rows="10" cols="80" id="source"></textarea>
</body>
</html>

⑵ JS使用new操作符創建對象的方法分析

本文實例講述了JS使用new操作符創建對象的方法。分享給大家供大家參考,具體如下:
在編寫js代碼時,我們有時會需要使用函數來模擬java中的類,並用它來產生對象,在定義了一個構造函數之後我們需要使用new操作符來調用調用函數才能得到我們想要的對象。例如:
<script>
function
Constructor(name){
this.name
=
name
}
var
person1
=
Constructor("張三");//undefined
var
person2
=
new
Constructor("張三");//得到一個對象{name:"張三"}
console.log(person1);
console.log(person2);
</script>
運行結果:
如果我們不使用new操作符調用函數,就只會簡單的執行函數,並把函數的返回值賦給person1,所以上面的例子中person1的值是undefined,.
如果我們使用new操作符調用構造函數,做了哪些事情呢?
1.構造函數沒有返回值
使用new操作符調用函數,會隱式的創建一個對象(我們這里稱這個對象為obj),這個對象obj是連接到構造函數的原型上的,即obj會繼承構造函數原型上的屬性方法,並且構造函數中的this也被綁定到了這個對象上,執行完成後這個對象會被作為返回值返回。
2.構造函數有返回值(這種情況比較少,至少我沒用過)
new出來的值由返回值的prototype而定
例如:
function
Constructor(name){
this.name
=
name
return
this.name;
}
var
person
=
new
Constructor("123");//Constructor
{name:
"123"};Object,因為基本類型的prototype都是Object
function
Constructor(name){
this.name
=
name
return
new
String(this.name);
}
var
person
=
new
Constructor("123");//String
{0:
"1",
1:
"2",
2:
"3",
length:
3,
[[PrimitiveValue]]:
"123"},
console.log(person);
運行結果:
感興趣的朋友可以使用在線HTML/CSS/JavaScript代碼運行工具:http://tools.jb51.net/code/HtmlJsRun測試上述代碼運行效果。
更多關於JavaScript相關內容還可查看本站專題:《javascript面向對象入門教程》、《JavaScript錯誤與調試技巧總結》、《JavaScript數據結構與演算法技巧總結》、《JavaScript遍歷演算法與技巧總結》及《JavaScript數學運算用法總結》
希望本文所述對大家JavaScript程序設計有所幫助。
您可能感興趣的文章:用方法封裝javascript的new操作符(一)淺談javascript中new操作符的原理JS重學系列之聊聊new操作符js構造函數創建對象是否加new問題JavaScript中使用構造器創建對象無需new的情況說明JavaScript
三種創建對象的方法JS
創建對象(常見的幾種方法)js中創建對象的幾種方式示例介紹js創建對象的幾種常用方式小結(推薦)js面向對象之常見創建對象的幾種方式(工廠模式、構造函數模式、原型模式)javascript的函數、創建對象、封裝、屬性和方法、繼承

⑶ 誰能給我一段Js的源代碼

哪裡是替換圖片位置,哪裡是替換圖片鏈接位置 看裡面的路徑一眼就知道了.有不懂的密我
<SCRIPT>
var widths=255;
var heights=255;
var counts=6;
img1=new Image ();img1.src='http://www.yesky.com/imagelist/2007/018/43rx42mql3ng.jpg';
img2=new Image ();img2.src='http://notebook.yesky.com/imagelist/2007/017/hub8x795v23m.jpg';
img3=new Image ();img3.src='http://www.yesky.com/imagelist/2007/017/dt741w2a2n42.jpg';
img4=new Image ();img4.src='http://www.yesky.com/imagelist/2007/016/hda926w5t574.jpg';
img5=new Image ();img5.src='http://diy.yesky.com/imagelist/2007/010/190g0pqjdbw7.jpg';
img6=new Image ();img6.src='http://www.yesky.com/imagelist/2007/015/67vtz4ew2m5s.jpg';
url1=new Image ();url1.src='http://www..com';
url2=new Image ();url2.src='http://www..com';
url3=new Image ();url3.src='http://www..com';
url4=new Image ();url4.src='http://www..com';
url5=new Image ();url5.src='http://www..com';
url6=new Image ();url6.src='http://www..com';
var nn=1;
var key=0;
function change_img()
{if(key==0){key=1;}
else if(document.all)
{document.getElementById("pic").filters[0].Apply();document.getElementById("pic").filters[0].Play(ration=2);}
eval('document.getElementById("pic").src=img'+nn+'.src');
eval('document.getElementById("url").href=url'+nn+'.src');
for (var i=1;i<=counts;i++){document.getElementById("xxjdjj"+i).className='axx';}
document.getElementById("xxjdjj"+nn).className='bxx';
nn++;if(nn>counts){nn=1;}
tt=setTimeout('change_img()',4000);}
function changeimg(n){nn=n;window.clearInterval(tt);change_img();}
document.write('<style>');
document.write('.axx{padding:1px 7px;border-left:#cccccc 1px solid;}');
document.write('a.axx:link,a.axx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#666;}');
document.write('a.axx:active,a.axx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#999;}');
document.write('.bxx{padding:1px 7px;border-left:#cccccc 1px solid;}');
document.write('a.bxx:link,a.bxx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
document.write('a.bxx:active,a.bxx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
document.write('</style>');
document.write('<div style="width:'+widths+'px;height:'+heights+'px;overflow:hidden;text-overflow:clip;">');
document.write('<div><a id="url" target="_blank"><img id="pic" style="border:0px;filter:progid:dximagetransform.microsoft.wipe(gradientsize=1.0,wipestyle=4, motion=forward)" width='+widths+' height='+heights+' /></a></div>');
document.write('<div style="filter:alpha(style=1,opacity=10,finishOpacity=80);background: #888888;width:100%-2px;text-align:right;top:-12px;position:relative;margin:1px;height:12px;padding:0px;margin:0px;border:0px;">');
for(var i=1;i<counts+1;i++){document.write('<a href="javascript:changeimg('+i+');" id="xxjdjj'+i+'" class="axx" target="_self">'+i+'</a>');}
document.write('</div></div>');
change_img();
</SCRIPT>

⑷ 在js里new數組怎麼做

用:var arr=new Array(); 或var arr=[];都可以實現創建數組。

⑸ 求js讀取資料庫數據顯示在頁面上的表中的功能源碼

js 可以讀資料庫 // JavaScript Document
var ServerIP="127.0.0.1";var conn,framePath,Style;
function kin_conn(){
var datasource="資料庫地址";
var filePath= window.location.href;
framePath=filePath.split("/frame")[0];
filePath=filePath.substring(8); //去掉file:///
filePath=filePath.split("/frame")[0];
datasource=filePath+"/db/"+datasource; try {
conn = new ActiveXObject("ADODB.Connection");
conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+datasource);
} catch (errer) {
alert(errer.description);
}
return true
}function conn_close(conn){
conn.close;
conn=null;
}function rs_close(rs){
rs.close;
rs=null;
}var request=req()
function req(){
var ocar=new Object;
ocar.mark="讀取地址欄地址";
ocar.querystring=function showcolor(ret){
var s = window.location.search.substr(1);
var aryVars = s.split('&');
for(var i=0;i<aryVars.length;i++)
{
var aryPair = aryVars[i].split("=");
if (aryPair[0]==ret){return aryPair[1];i=aryVars+1;}
}
}
return ocar;
} var S=request.querystring("S");
if (S==null){window.location.href="../index.html";}
kin_conn();
//連接資料庫
var sc = new ActiveXObject("ADODB.Recordset");
var sql="select * from [News_smallclass] where [smallclassID]="+S;
sc.open(sql, conn, 1,1 );
if (sc.recordcount<1) {alert("地址錯誤");window.location.href="../index.html";}

var newsid=""+sc("id")+""; //以前用網站轉CD時作的一個東東.核心部分就是這個,需要的話我可以把我作的東西發給你.不過沒有作完 hehe

⑹ 什麼是js源碼

就是js第*版上的代碼(書上寫過的代碼),在官網能下

⑺ js源碼解釋

處理圖片的一段js腳本,
var GIF89a=document.location.href;//先取本頁的鏈接
GIF89a=GIF89a.substring(0,GIF89a.lastIndexOf('/'));//截取最後一個「/」後面的部分,也就是文件的名字
然後在本頁中添加一個object

⑻ JS如何查找源代碼

<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>遠程網頁源代碼讀取</title>

<style type="text/css">
/* 頁面字體樣式 */
body, td, input, textarea {
font-family:Arial;
font-size:12px;
}
</style>

<script type="text/javascript">
//用於創建XMLHttpRequest對象
function createXmlHttp() {
//根據window.XMLHttpRequest對象是否存在使用不同的創建方式
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest(); //FireFox、Opera等瀏覽器支持的創建方式
} else {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");//IE瀏覽器支持的創建方式
}
}

//直接通過XMLHttpRequest對象獲取遠程網頁源代碼
function getSource() {
var url = document.getElementById("url").value; //獲取目標地址信息

//地址為空時提示用戶輸入
if (url == "") {
alert("請輸入網頁地址。");
return;
}

document.getElementById("source").value = "正在載入……"; //提示正在載入
createXmlHttp(); //創建XMLHttpRequest對象
xmlHttp.onreadystatechange = writeSource; //設置回調函數
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}

//將遠程網頁源代碼寫入頁面文字區域
function writeSource() {
if (xmlHttp.readyState == 4) {
document.getElementById("source").value = xmlHttp.responseText;
}
}
</script>
</head>

<body>
<h1>遠程網頁源代碼讀取</h1>

<div>
地址:<input type="text" id="url">
<input type="button" onclick="getSource()" value="獲取源碼">
</div>

<textarea rows="10" cols="80" id="source"></textarea>

</body>
</html>
我也是別人那抄的 你試試吧 好的話給我個最佳

⑼ 請問這段JS代碼是什麼意思

你這個應該是一小部分js源碼

aEventList是個事件列表也可以叫做事件數組,這個數組本身在js中是沒有的,是手動創建的的事件對象存儲器,它主要用於裝載一系列的事件存儲的。

new Event是一個事件系列的對象類,在js中本身也是沒有new Event()的,這也是手動創建的。如果是你的項目你可以在項目中搜索下,肯定會找到function Event()或者var Event = function(){}類似這種的js函數

⑽ js new Array數組

array數組可以自動擴展長度,用戶直接new Array(100)的話,循環就會進行一百次。

具體有什麼作用,可以參考下面的例子:

varx=newArray(100);

for(vari=0;i<x.length;i++)x[i]=i*i;

(10)jsnew的源碼擴展閱讀:

使用規則

1、數組的類型實際上是指數組元素的取值類型,對於同一個數組,其所有元素的數據類型都是相同的。

2、數組名的書寫規則應符合標識符的書寫規定。

3、數組名不能與其它變數名相同。

4、可以只給部分元素賦初值,當{ }中值的個數少於元素個數時,只給前面部分元素賦值。

例如:static int a[10]={0,1,2,3,4};表示只給a[0]~a[4]5個元素賦值,而後5個元素自動賦0值。

閱讀全文

與jsnew的源碼相關的資料

熱點內容
嬰兒武打片 瀏覽:642
師徒訓誡小說推薦 瀏覽:548
好後綴演算法 瀏覽:19
關閉終端的命令 瀏覽:511
有聲黃讀 瀏覽:542
三大頂級動作片推薦胸大的女人電影 瀏覽:367
哺乳期誘惑電影 瀏覽:706
哪些雲伺服器可以搭建郵件伺服器 瀏覽:687
美國試禁忌當上演員 瀏覽:304
hqss/vod/index.asp 瀏覽:404
男主很帥的歐美大尺度電影 瀏覽:356
怎麼消除安卓的系統通知 瀏覽:478
程序員3萬4是稅後嗎 瀏覽:868
javagui窗口 瀏覽:522
風月片網站動漫 瀏覽:289
電影拉幫套 瀏覽:745
鴉王電影國語版 瀏覽:600
造機甲的黑科技小說 瀏覽:780
歐美在線觀看網站 瀏覽:385
python整蠱代碼大全 瀏覽:458