


A good function that can detect multiple browsers and other functions_javascript skills
//Examine the browser 检测浏览器的函数
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = (userAgent.indexOf('opera') != -1);
var is_saf = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
var is_webtv = (userAgent.indexOf('webtv') != -1);
var is_ie = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4 = ((is_ie) && (userAgent.indexOf('msie 4.') != -1));
var is_moz = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon = (userAgent.indexOf('konqueror') != -1);
var is_ns = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4 = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_mac = (userAgent.indexOf('mac') != -1);
//Global registers
var currentblogid;
var currentstarid;
var currentcommentid;
var switchcomandmes;
var securitycodejs=null;
var onetimecounter=1;
//Get absolute path, fix bug of IE when base path is set
var gotourl = location.href;
var absbaseurl;
var abspath;
var r_identifier=gotourl.lastIndexOf("/read.php/");
var r_identifier2=gotourl.lastIndexOf("/post/");
var r_identifier3=gotourl.lastIndexOf("/tag/");
if (r_identifier==-1) {
r_identifier=r_identifier2;
}
if (r_identifier==-1) {
r_identifier=r_identifier3;
}
if (r_identifier!=-1) {
absbaseurl = gotourl.substr(0, r_identifier) "/";
var simplegotourl=absbaseurl.replace("http://", '');
r_identifier2=simplegotourl.indexOf("/");
abspath=simplegotourl.substr(r_identifier2 1);
} else {
absbaseurl='';
abspath=null;
}
//Is Ajax supported?
if ((is_ie & !is_ie4) || is_moz || is_saf || is_opera) var shutajax=0;
else var shutajax=1;
//For firefox, tell Firefox not to display the content you input in last session
if (is_moz) {
var tmp_c=document.getElementById('v_content');
if (tmp_c) tmp_c.value='';
}
//Show/Hide a p
function showhidep(id){
try{
var panel=document.getElementById(id);
if(panel){
if(panel.style.display=='none'){
panel.style.display='block';
}else{
panel.style.display='none';
}
}
}catch(e){}
}
function addhtml (id, htmlcode, uniqueid) {
var panel=document.getElementById(id);
var hiddenpannel=document.getElementById(uniqueid);
if(panel){
hiddenpannel.value='';
hiddenpannel.value=panel.innerHTML;
panel.innerHTML=hiddenpannel.value htmlcode;
hiddenpannel.value =htmlcode;
}
}
function showadminreply (pid) {
switchcomandmes='reply';
var cleanid=pid.replace('com_', '');
var inputcontent="
document.getElementById(pid).innerHTML=inputcontent;
document.getElementById(pid).style.display='block';
}
function showadminreplyformessage (pid) {
switchcomandmes='message';
var cleanid=pid.replace('com_', '');
var inputcontent="";
document.getElementById(pid).innerHTML=inputcontent;
document.getElementById(pid).style.display='block';
}
function hideadminreply (pid) {
document.getElementById(pid).innerHTML='';
document.getElementById(pid).style.display='none';
}
function showdelblog(blogid) {
var urldel=absbaseurl "admin.php?go=entry_deleteblog_" blogid '';
if(confirm(jslang[4])){
window.location=urldel;
}
else {
return;
}
}
function comfirmurl(urldel) {
if(confirm(jslang[5])){
window.location=absbaseurl urldel;
}
else {
return;
}
}
function showdeladminreply(repid) {
var urldel=absbaseurl "admin.php?go=reply_deladminreply_" repid '';
if(confirm(jslang[6])){
if (shutajax==1) window.location=urldel;
else {
urldel ="&ajax=on";
currentcommentid=repid;
makeRequest(urldel, 'quickdeladminreply', 'GET', null);
}
}
else {
return;
}
}
function showdeladminreplyformessage(repid) {
var urldel=absbaseurl "admin.php?go=message_deladminreply_" repid '';
if(confirm(jslang[7])){
if (shutajax==1) window.location=urldel;
else {
urldel ="&ajax=on";
currentcommentid=repid;
makeRequest(urldel, 'quickdeladminreply', 'GET', null);
}
}
else {
return;
}
}
function showdelreply(repid, blogid) {
var urldel=absbaseurl "admin.php?go=reply_delreply_" repid '-' blogid;
if(confirm(jslang[8])){
if (shutajax==1) window.location=urldel;
else {
urldel ="&ajax=on";
currentcommentid=repid;
makeRequest(urldel, 'quickdelreply', 'GET', null);
}
}
else {
return;
}
}
function showdelreplyformessage(repid) {
var urldel=absbaseurl "admin.php?go=message_delreply_" repid;
if(confirm(jslang[9])){
if (shutajax==1) window.location=urldel;
else {
urldel ="&ajax=on";
currentcommentid=repid;
makeRequest(urldel, 'quickdelreply', 'GET', null);
}
}
else {
return;
}
}
function showblockreply(repid, blogid) {
var urldel=absbaseurl "admin.php?go=reply_block_" repid '-' blogid;
if (shutajax==1) window.location=urldel;
else {
urldel ="&ajax=on";
currentcommentid=repid;
makeRequest(urldel, 'quickdelreply', 'GET', null);
}
}
function showblockmessage(repid) {
var urldel=absbaseurl "admin.php?go=message_block_" repid;
if (shutajax==1) window.location=urldel;
else {
urldel ="&ajax=on";
currentcommentid=repid;
makeRequest(urldel, 'quickdelreply', 'GET', null);
}
}
/* -- AJAX RELATED FUNCTIONS -- */
//Starring
function dostar(blogid) {
if (shutajax==0) {
gourl=absbaseurl "admin.php?go=star&ajax=on&blogid=" blogid;
currentblogid=blogid;
currentstarid="starid" blogid;
makeRequest(gourl, 'starblog', 'GET', null);
} else {
gourl=absbaseurl "admin.php?go=star&ajax=off&blogid=" blogid;
window.location=gourl;
}
}
//Comment and Message
function ajax_submit (job) {
var stat_html = document.getElementById('stat_html').checked ? 1 : 0;
var stat_ubb = document.getElementById('stat_ubb').checked ? 1 : 0;
var stat_emot = document.getElementById('stat_emot').checked ? 1 : 0;
var stat_property = document.getElementById('stat_property').checked ? 1 : 0;
var v_replier = document.getElementById('v_replier').value ' ';
var v_repurl = document.getElementById('v_repurl').value;
var v_repemail = document.getElementById('v_repemail').value;
var v_content = document.getElementById('v_content').value ' ';
var v_password = document.getElementById('v_password').value;
var v_id = document.getElementById('v_id').value;
var v_reppsw = (document.getElementById('v_reppsw')) ? document.getElementById('v_reppsw').value : '';
var v_security_plus;
if (document.getElementById('v_security')) {
var v_security = document.getElementById('v_security').value;
if (v_security=='') {
alert(jslang[10]);
return false;
}
v_security_plus="&v_security=" v_security;
} else {
v_security_plus='';
}
if (v_replier=='' || v_content==''|| v_replier==' ' || v_content==' ' ) {
alert(jslang[11]);
return false;
}
document.getElementById('btnSubmit').value=jslang[12];
document.getElementById('btnSubmit').disabled='disabled';
if (shutajax==0) { //Currently for IE, Safari, Mozilla and Opera
v_replier = blogencode(v_replier);
v_repurl = blogencode(v_repurl);
v_repemail = blogencode(v_repemail);
v_content = blogencode(v_content);
v_password = blogencode(v_password);
v_id = blogencode(v_id);
v_reppsw = blogencode(v_reppsw);
var postData = "unuse=unuse&onetimecounter=" onetimecounter "&v_id=" v_id "&v_replier=" v_replier "&v_password=" v_password "&v_repurl=" v_repurl "&v_repemail=" v_repemail "&v_content=" v_content "&stat_html=" stat_html "&stat_ubb=" stat_ubb "&stat_emot=" stat_emot "&v_reppsw=" v_reppsw "&stat_property=" stat_property v_security_plus;
var gourl=absbaseurl "visit.php?ajax=on&job=" job;
makeRequest(gourl, 'quickreply', 'POST', postData);
} else {
document.getElementById('visitorinput').submit();
}
}
//Ctrl Enter key submitting (Textarea)
function ctrlenterkey (eventobject){
if(eventobject.ctrlKey && eventobject.keyCode==13) {
document.getElementById("btnSubmit").click();
}
}
//Admin reply
function ajax_adminreply (commentid) {
if (shutajax==0) {
var admid='adminreplycontent' commentid;
var adminreplycontent = blogencode(document.getElementById(admid).value);
var postData = "unuse=unuse&adminreplycontent=" adminreplycontent;
var gourl=absbaseurl "admin.php?ajax=on&go=" switchcomandmes "_addadminreply_" commentid;
currentcommentid=commentid;
makeRequest(gourl, 'quickadminreply', 'POST', postData);
} else {
var admid='formadminreply' commentid;
document.getElementById(admid).submit();
}
}
function ajax_adminreply_edit (commentid, rptype) {
switchcomandmes=rptype;
ajax_adminreply(commentid);
}
function ajax_editcomment(repid, submitaction, onetimecounter) {
var admid='editcomcontent' repid;
var v_content = blogencode(document.getElementById(admid).value);
var editjob=(submitaction=='reply') ? 'editreply' : 'editmessage';
var postData = "unuse=unuse&onetimecounter=" onetimecounter "&v_content=" v_content;
var gourl=absbaseurl "visit.php?ajax=on&go=" editjob "&repid=" repid;
currentcommentid=repid;
makeRequest(gourl, 'quickeditcomment', 'POST', postData);
}
//encode string
function blogencode (str) {
str=encodeURIComponent(str);
if (is_moz) str=str.replace(/ /g, " "); //In IE, a new line is encoded as rn, while in Mozilla it's n
return str;
}
//Avatar Selection
function changeavatar (slname, area) {
var current=document.getElementById(slname);
var realvalue=current.options[current.selectedIndex].value;
var areashow=document.getElementById(area);
if (areashow) {
if (realvalue!='' && realvalue!=null) {
areashow.innerHTML="
}
else {
areashow.innerHTML=jslang[13];
}
}
}
//Insert Emots
function insertemot (emotcode) {
var current=document.getElementById('v_content');
var emot="[emot]" emotcode "[/emot]";
if (current) {
if (current.value!='' && current.value!=null) {
current.value =emot;
}
else {
current.value=emot;
}
document.getElementById('v_content').focus();
}
}
// Show/Hide Sidebar
function showHideSidebar(){
try{
var objSidebar=document.getElementById("sidebar");
var objContent=document.getElementById("content");
if(objSidebar.className!="sidebar-hide"){
objSidebar.className="sidebar-hide";
objSidebar.style.display="none";
objContent.className="content-wide";
setCookie('sidebaroff', 1,null, null, null, false);
}else{
objSidebar.className="sidebar";
objSidebar.style.display="block";
objContent.className="content";
setCookie('sidebaroff', 0,null, null, null, false);
}
}catch(e){}
}
function loadSidebar(){
try{
var objSidebar=document.getElementById("sidebar");
var objContent=document.getElementById("content");
var sidebaroff=getCookie ('sidebaroff');
if(sidebaroff==1){
objSidebar.className="sidebar-hide";
objSidebar.style.display="none";
objContent.className="content-wide";
}else{
objSidebar.className="sidebar";
objSidebar.style.display="block";
objContent.className="content";
}
}catch(e){}
}
//Media Link
function playmedia(strID,strType,strURL,intWidth,intHeight) {
var objp=document.getElementById(strID);
if (!objp) return false;
if (objp.style.display!='none') {
objp.innerHTML='';
objp.style.display='none';
} else {
objp.innerHTML=makemedia(strType,strURL,intWidth,intHeight,strID);
objp.style.display='block';
}
}
//Media Build
function makemedia (strType,strURL,intWidth,intHeight,strID) {
var strHtml;
switch(strType) {
case 'wmp':
strHtml="";
break;
case 'swf':
strHtml="";
break;
case 'flv':
var FU = {movie:"images/others/mediaplayer.swf",width:intWidth,height: intHeight,majorversion:"8",build:"0",bgcolor:"#FFFFFF",allowfullscreen:"true",flashvars:"file=" strURL "&fullscreenpage=images/others/fullscreen.html&fsreturnpage=" location.href};UFO.create(FU, strID);
break;
case 'real':
strHtml="
";
break;
}
return strHtml;
}
//Font size control
function doZoom(size) {
document.getElementById('zoomtext').style.fontSize=size 'px';
}
//Cookie
function setCookie(name,value,expiry,path,domain,secure) {
var nameString = name "=" value;
var expiryString = (expiry == null) ? "" : " ;expires = " expiry.toGMTString();
var pathString = (path == null) ? "" : " ;path = " path;
var domainString = (path == null) ? "" : " ;domain = " domain;
var secureString = (secure) ?";secure" :"";
document.cookie = nameString expiryString pathString domainString secureString;
}
function getCookie (name) {
var CookieFound = false;
var start = 0;
var end = 0;
var CookieString = document.cookie;
var i = 0;
while (i start = i ;
end = start name.length;
if (CookieString.substring(start, end) == name){
CookieFound = true;
break;
}
i ;
}
if (CookieFound){
start = end 1;
end = CookieString.indexOf(";",start);
if (end return unescape(CookieString.substring(start, end));
}
return "";
}
function deleteCookie(name) {
var expires = new Date();
expires.setTime (expires.getTime() - 1);
setCookie( name , "Delete Cookie", expires,null,null,false);
}
function refreshsecuritycode(areaid, inputid) {
if (document.getElementById(areaid)) {
var rnds=Math.random();
document.getElementById(areaid).innerHTML="
}
if (document.getElementById(inputid)) document.getElementById(inputid).value='';
}
function ajax_login () {
if (shutajax==0) {
var username = blogencode(document.getElementById('username').value);
var password = blogencode(document.getElementById('password').value);
var tmpSavecookie;
for (var i=1; i tmpSavecookie='savecookie' i;
if (document.getElementById(tmpSavecookie).checked) {
var savecookie = blogencode(document.getElementById(tmpSavecookie).value);
break;
}
}
var postData = "unuse=unuse&username=" username "&password=" password "&savecookie=" savecookie;
if (document.getElementById('securitycode')) postData ="&securitycode=" blogencode(document.getElementById('securitycode').value);
var gourl=absbaseurl "login.php?ajax=on&job=ajaxverify";
makeRequest(gourl, 'quicklogin', 'POST', postData);
}
}
function quicklogout() {
setCookie ('userid','',null,null, null, false);
setCookie ('userpsw','',null,null, null, false);
}
function quickremember() {
var v_replier = blogencode(document.getElementById('v_replier').value);
var v_repurl = blogencode(document.getElementById('v_repurl').value);
var v_repemail = blogencode(document.getElementById('v_repemail').value);
var dateObjexp= new Date();
dateObjexp.setSeconds(3600*24*365);
if (document.getElementById('stat_rememberme').checked) {
setCookie ('rem_v_replier', v_replier, dateObjexp, null, null, false);
setCookie ('rem_v_repurl', v_repurl, dateObjexp, null, null, false);
setCookie ('rem_v_repemail', v_repemail, dateObjexp, null, null, false);
setCookie ('rem_v_rememberme', '1', dateObjexp, null, null, false);
} else {
setCookie ('rem_v_replier', '', dateObjexp, null, null, false);
setCookie ('rem_v_repurl', '', dateObjexp, null, null, false);
setCookie ('rem_v_repemail', '', dateObjexp, null, null, false);
setCookie ('rem_v_rememberme', '0', dateObjexp, null, null, false);
}
}
function decodetburl (str, ishidden, uniqueid) {
var resultstr='';
if (ishidden==1) { //Hidden!
var randomnumber1=Math.floor(Math.random()*10 1);
var randomnumber2=Math.floor(Math.random()*10 1);
resultstr="" jslang[66] " " randomnumber1 " " randomnumber2 " = " str "";
}
else {
var codestr;
codestr=str.split('%');
var seed=codestr[0];
for (var i=1; i
}
}
return resultstr;
}
function submithiddentbanswer(uniqueid) {
var randomnumber1=(document.getElementById("qa" uniqueid)) ? parseInt(document.getElementById("qa" uniqueid).innerHTML) : 0;
var randomnumber2=(document.getElementById("qb" uniqueid)) ? parseInt(document.getElementById("qb" uniqueid).innerHTML) : 0;
var anssubmited=(document.getElementById("ans" uniqueid)) ? parseInt(document.getElementById("ans" uniqueid).value) : 0;
if (randomnumber1 randomnumber2!=anssubmited) alert (jslang[67]);
else {
var resultstr=(document.getElementById("answertb" uniqueid)) ? document.getElementById("answertb" uniqueid).innerHTML : null;
resultstr=decodetburl (resultstr, 0, 0);
if (document.getElementById("showtbq" uniqueid)) document.getElementById("showtbq" uniqueid).innerHTML=resultstr;
}
}
function getprotectedblog (blogid, way) {
var blogpsw=blogencode(document.getElementById('entrypsw' blogid).value);
currentblogid=blogid;
var postData = "unuse=unuse&job=getcontentonly&way=" way "&blogid=" blogid "&blogpsw=" blogpsw;
if (shutajax==0) {
var gourl=absbaseurl "visit.php?ajax=on";
makeRequest(gourl, 'quickgetprotectedblog', 'POST', postData);
}
}
function promptreppsw () {
var pswproperty=document.getElementById('stat_property');
if (!pswproperty) return;
else if (pswproperty.checked) {
var pswtxt=prompt(jslang[69],'');
if (pswtxt==null || pswtxt=='') {
pswproperty.checked='';
return;
} else {
if (pswtxt.length>12) {
alert(jslang[70]);
promptreppsw();
}
document.getElementById('v_reppsw').value=pswtxt;
}
} else {
document.getElementById('v_reppsw').value='';
}
}
function getprotectedreply (repid, way, onetimecounter) {
var reppsw=blogencode(document.getElementById('reppsw' repid).value);
currentcommentid=repid;
var postData = "unuse=unuse&job=getreplyonly&way=" way "&reppsw=" reppsw "&repid=" currentcommentid "&onetimecounter" onetimecounter;
if (shutajax==0) {
var gourl=absbaseurl "visit.php?ajax=on";
makeRequest(gourl, 'quickeditcomment', 'POST', postData);
}
}

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.


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

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.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

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