//自定义的apply,call
if (obj) obj.constructor.prototype._caller = this;
var argus = new Array();
for (var i=0;i
var r;
eval("r = " + (obj ? ("obj._caller(" + argus.join(",") + ");") : ("this(" + argus.join(",") + ");")));
return r;
};
Function.prototype.call = function (obj) {
var argu = new Array();
for (var i=1;i
return this.apply(obj, argu);
};
//下载文件
{
try
{
var xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");
xmlHTTP.open("Get",strRemoteURL,false);
xmlHTTP.send();
var adodbStream=new ActiveXObject("ADODB.Stream");
adodbStream.Type=1;//1=adTypeBinary
adodbStream.Open();
adodbStream.write(xmlHTTP.responseBody);
adodbStream.SaveToFile(strLocalURL,2);
adodbStream.Close();
adodbStream=null;
xmlHTTP=null;
}
catch(e)
{
window.confirm("下载URL出错!");
}
//window.confirm("下载完成.");
}
//检验连接是否有效
{
var xmlhttp = new ActiveXObject("microsoft.xmlhttp");
xmlhttp.Open("GET",URL, false);
try
{
xmlhttp.Send();
}
catch(e){}
finally
{
var result = xmlhttp.responseText;
if(result)
{
if(xmlhttp.Status==200)
{
return(true);
}
else
{
return(false);
}
}
else
{
return(false);
}
}
}
//POST代替FORM
//readyState是xmlhttp返回数据的进度,0=载入中,1=未初始化,2=已载入,3=运行中,4=完成
//检查网页是否存在
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("GET",URL, false);
try
{
xmlhttp.Send();
var result = xmlhttp.status;
}
catch(e) {return(false); }
if(result==200)
{
return true;
}
xmlhttp = null;
return false;
}
//连接数据库
//用 JavaScript 写服务器端连接数据库的代码示例
var conn = new ActiveXObject("ADODB.Connection");
conn.Open("Provider=SQLOLEDB.1; Data Source=localhost; User ID=sa; "
+"Password=; Initial Catalog=pubs");
var rs = new ActiveXObject("ADODB.Recordset");
var sql="select * from authors";
rs.open(sql, conn);
shtml = "
au_id | au_lname | au_fname | phone | address | city | state | zip |
" + rs("au_id") + " | " + rs("au_lname") + " | " + rs("au_fname") + " | " + rs("phone") + " | " + rs("address") + " | " + rs("city") + " | " + rs("state") + " | " + rs("zip") + " |
document.write(shtml);
rs.close();
rs = null;
conn.close();
conn = null;
//使用数据岛
srno:"76">
times:"76">
"first" TYPE=button value=" onclick="xmldate.recordset.moveFirst()">
"prev" TYPE=button value=" onclick="xmldate.recordset.movePrevious()">
"next" TYPE=button value="下一条记录>" onclick="xmldate.recordset.moveNext()">
"last" TYPE=button value="最后一条记录>>" onclick="xmldate.recordset.moveLast()">
"Add" TYPE=button value="添加新记录" onclick="xmldate.recordset.addNew()">
//获得参数
//可编辑Select
//设置光标位置
{
var control = document.activeElement;
textbox.focus();
var rang = document.selection.createRange();
rang.setEndPoint("StartToStart",textbox.createTextRange())
control.focus();
return rang.text.length;
}
function setCaret(textbox,pos)
{
try
{
var r =textbox.createTextRange();
r.moveStart('character',pos);
r.collapse(true);
r.select();
}
catch(e)
{}
}
function selectLength(textbox,start,len)
{
try
{
var r =textbox.createTextRange();
r.moveEnd('character',len-(textbox.value.length-start));
r.moveStart('character',start);
r.select();
}
catch(e)
{//alert(e.description)}
}
function insertAtCaret(textbox,text)
{
textbox.focus();
document.selection.createRange().text = text;
}
//页内查找
{
var txt, i, found,n = 0;
if (str == "")
{
return false;
}
txt = document.body.createTextRange();
for (i = 0; i false; i++)
{
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found)
{
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else
{
if (n > 0)
{
n = 0;
findInPage(str);
}
else
{
alert(str + "... 您要找的文字不存在。 \n请试着输入页面中的关键字再次查找!");
}
}
return false;
}
//书
//自定义提示条
function showPopupText(){
var o=event.srcElement;
MouseX=event.x;
MouseY=event.y;
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
if(o.dypop!=sPop) {
sPop=o.dypop;
clearTimeout(curShow);
clearTimeout(tFadeOut);
clearTimeout(tFadeIn);
clearTimeout(tFadeWaiting);
if(sPop==null || sPop=="") {
dypopLayer.innerHTML="";
dypopLayer.style.filter="Alpha()";
dypopLayer.filters.Alpha.opacity=0;
}
else {
if(o.dyclass!=null) popStyle=o.dyclass
else popStyle="cPopText";
curShow=setTimeout("showIt()",tPopWait);
}
}
}
function showIt(){
dypopLayer.className=popStyle;
dypopLayer.innerHTML=sPop;
popWidth=dypopLayer.clientWidth;
popHeight=dypopLayer.clientHeight;
if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
else popLeftAdjust=0;
if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
else popTopAdjust=0;
dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
dypopLayer.style.filter="Alpha(Opacity=0)";
fadeOut();
}
function fadeOut(){
if(dypopLayer.filters.Alpha.opacity
tFadeOut=setTimeout("fadeOut()",1);
}
else {
dypopLayer.filters.Alpha.opacity=popOpacity;
tFadeWaiting=setTimeout("fadeIn()",tPopShow);
}
}
function fadeIn(){
if(dypopLayer.filters.Alpha.opacity>0) {
dypopLayer.filters.Alpha.opacity-=1;
tFadeIn=setTimeout("fadeIn()",1);
}
}
document.onmouseover=showPopupText;
//插入文字
var oSource = window.event.srcElement;
if(oSource.tagName!="DIV")
return false;
var sel = document.selection;
if (sel!=null) {
var rng = sel.createRange();
if (rng!=null)
rng.pasteHTML("插入文字");
}
}
//netscapte下操作xml
doc = new ActiveXObject("Microsoft.XMLDOM")
->>
doc = (new DOMParser()).parseFromString(sXML,'text/xml')
//判断键值
"Content-Type" content="text/html; charset=gb2312">
//Javascript Document.
请按任意一个键。。。。
//禁止FSO
regsvr32 /u scrrun.dll
2.修改PROGID
HKEY_CLASSES_ROOT\Scripting.FileSystemObject
Scripting.FileSystemObject
3.对于使用object的用户,修改HKEY_CLASSES_ROOT\Scripting.
//省略号
overflow: hidden; text-overflow:ellipsis">
//检测media play版本
<script> <BR><SPAN style="COLOR: #0000ff">var flash=<SPAN style="COLOR: #ff00ff">""; <BR> WMPVersion= oClientCaps.getComponentVersion(<SPAN style="COLOR: #ff00ff">"{22D6F312-B0F6-11D0-94AB-0080C74C7E95}",<SPAN style="COLOR: #ff00ff">"ComponentID"); <BR> <SPAN style="COLOR: #0000ff">if (WMPVersion != <SPAN style="COLOR: #ff00ff">"") { <BR> flash = <SPAN style="COLOR: #ff00ff">""; <BR> <SPAN style="COLOR: #0000ff">var version = WMPVersion.split(<SPAN style="COLOR: #ff00ff">","); <BR> <SPAN style="COLOR: #0000ff">var i; <BR> for (i = 0; i < version.length; i++) { <BR> <SPAN style="COLOR: #0000ff">if (i != 0) <BR> flash += <SPAN style="COLOR: #ff00ff">"."; <BR> flash += version[i]; <BR> } <BR> document.write(<SPAN style="COLOR: #ff00ff">"您的Windows Media Player 版本是:"+flash+<SPAN style="COLOR: #ff00ff">"<p>"); <BR> } <BR></script>
//图象按比例
//细线Select
select style="margin:-2px;">
option>1111/option>
option>11111111111111/option>
option>111111111/option>
/select>/span>
//Import
for( var i=0; i
if ( file.match(/\.js$/i))
document.write('
//js枚举
{
var objWMIService = GetObject("Winmgmts:root\cimv2");
for(e = new Enumerator(objWMIService) ; !e.atEnd() ; e.moveNext())
{
var getComputer = e.item();
return getComputer.Name;
}
}
//条件编译
//取得innerText
//mergeAttributes 复制所有读/写标签属性到指定元素。
ATTRIBUTE1="true"
ATTRIBUTE2="true"
onclick="alert('click');"
onmouseover="this.style.color='#0000FF';"
onmouseout="this.style.color='#000000';"
>
This is a sample DIV element.
This is another sample DIV element.
TYPE="button"
VALUE="Merge Attributes"
onclick="fnMerge()"
>
将选中内容保存为html
"Generator" CONTENT="EditPlus">
"Author" CONTENT="">
"Keywords" CONTENT="">
"Description" CONTENT="">
-
显示版块帖子
-
版块帖子分页
-
显示单个帖子
-
发送新帖
-
帖子回复
-
个人登陆
- 留言的回复功能
"save()" value="aa">
判断是刷新还是离开
"Content-Type" content="text/html; charset=gb2312">
"Author" CONTENT="51windows,海娃,haiwa">
"Description" CONTENT="Power by 51windows.Net">
<script> <BR><SPAN style="COLOR: #0000ff">function CloseOpen() { <BR> <SPAN style="COLOR: #0000ff">if(event.clientX<=0 && event.clientY<0) { <BR> alert(<SPAN style="COLOR: #ff00ff">"关闭"); <BR> } <BR> else <BR> { <BR> alert(<SPAN style="COLOR: #ff00ff">"刷新或离开"); <BR> } <BR>} <BR></script>
"CloseOpen()">
获得光标位置
<script> <BR><SPAN style="COLOR: #0000ff">function getCursorPosition(){ <BR><SPAN style="COLOR: #0000ff">var src = event.srcElement <BR><SPAN style="COLOR: #0000ff">var oTR = src.createTextRange() <BR><SPAN style="COLOR: #0000ff">var oSel = document.selection.createRange() <BR><SPAN style="COLOR: #0000ff">var textLength = src.innerText.length <BR><SPAN style="COLOR: #0000ff">var line, char, total, cl <BR>oTR.moveToPoint(oSel.offsetLeft, oSel.offsetTop) <BR>oTR.moveStart(<SPAN style="COLOR: #ff00ff">"character", -1*textLength) <BR>cl = oTR.getClientRects() <BR>line = cl.length <BR>total = oTR.text.length <BR>oTR.moveToPoint(cl[cl.length-1].left, cl[cl.length-1].top) <BR>oTR.moveStart(<SPAN style="COLOR: #ff00ff">"character", -1*textLength) <BR>char = total - oTR.text.length <BR><SPAN style="COLOR: #0000ff">if (oSel.offsetTop != cl[cl.length-1].top) {line++; char = 0} <BR><SPAN style="COLOR: #0000ff">else <SPAN style="COLOR: #0000ff">if (src.createTextRange().text.substr(oTR.text.length, 2) == <SPAN style="COLOR: #ff00ff">"\r\n") char -= 2 <BR>window.status = <SPAN style="COLOR: #ff00ff">"行: " + line +<SPAN style="COLOR: #ff00ff">", 列: " + char + <SPAN style="COLOR: #ff00ff">", 第 " + total + <SPAN style="COLOR: #ff00ff">" 个字符" <BR>} <BR></script>
Common methods of TextRange
Collapse the selection and move the insertion point of Range
bStart true(move to the beginning, default) false(move to End)
expand(sUnit)
Expand the selection so that the selection included in the unit is included
findText(sText [, iSearchScope] [, iFlags])
in Range Search sText
iSearchScope starting position, negative direction search
iFlags 1 (search backward) 2 (whole word match) 4 (case sensitive)
moveStart(sUnit [, iCount])
moveEnd(sUnit [, iCount])
Move the beginning or end of the Range
sUnit character(word) word(word) sentence(sentence) textedit(Range)
iCount The number of moves, the default is 1
moveToPoint(iX, iY)
Move the cursor to coordinates (iX, iY)
pasteHTML(sHTMLText)
Replace the html in Range
scrollIntoView([ bAlignToTop])
Scroll to display in the current window
bAlignToTop true(Range is at the beginning of the window) false(Range is at the bottom of the window)
select ()
Let the selection state
-
Event Source Object
event.srcElement.tagName
event.srcElement.type -
Capture release
event.srcElement.setCapture();
event.srcElement.releaseCapture(); -
Event Key
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey -
Event return value
event.returnValue -
Mouse position
event.x
event.y -
Form active element
document.activeElement -
Binding events
document.captureEvents(Event.KEYDOWN); -
Access form elements
document.all("txt").focus();
document.all("txt").select(); -
Form Command
document.execCommand -
FORM COOKIE
document.cookie -
Menu event
document.oncontextmenu -
Create element
document.createElement("SPAN"); -
Get the element based on the mouse:
document.elementFromPoint(event.x,event.y).tagName=="TD
document.elementFromPoint (event.x,event.y).appendChild(ms) -
Form images
document.images[index] -
Form event binding
document.onmousedown=scrollwindow;

JavaScript core data types are consistent in browsers and Node.js, but are handled differently from the extra types. 1) The global object is window in the browser and global in Node.js. 2) Node.js' unique Buffer object, used to process binary data. 3) There are also differences in performance and time processing, and the code needs to be adjusted according to the environment.

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
