A nice function to detect multiple browsers and other features 1th/2 page _javascript tips

Source: Internet
Author: User
Examine the browser detects browser functions
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_o Pera) && (!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 isn't to display the content of
if (Is_moz) {
var Tmp_c=document.getelementbyid (' V_content ');
if (tmp_c) tmp_c.value= ';
}

Show/hide a DIV
function Showhidediv (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 (divid) {
switchcomandmes= ' reply ';
var cleanid=divid.replace (' Com_ ', ');
var inputcontent= "<form action=" "+absbaseurl+" Admin.php?go=reply_addadminreply_ "+cleanid+" ' method= ' post ' id= ' Formadminreply "+cleanid+" ' > ';
inputcontent+=jslang[0]+ "<br/><textarea cols= ' rows= ' 3 ' name= ' adminreplycontent ' id= '" adminreplycontent "+cleanid+" ' ></textarea><br/> ';
inputcontent+= "<input type= ' button ' onclick=\" ajax_adminreply (' "+cleanid+"); return false;\ "value= '" +jslang[1]+ "' class= ' button '/> <input type= ' reset ' value= '" +jslang[2]+ ' ' class= ' button ' /> <input type= ' button ' value= ' +jslang[3]+ ' ' onclick=\ ' hideadminreply (' +divid+ '); \ class= ' button '/> </form> ";
document.getElementById (divID). Innerhtml=inputcontent;
document.getElementById (divid). style.display= ' block ';
}

function Showadminreplyformessage (divid) {
switchcomandmes= ' message ';
var cleanid=divid.replace (' Com_ ', ');
var inputcontent= "<form action=" "+absbaseurl+" Admin.php?go=message_addadminreply_ "+cleanid+" ' method= ' post ' id= ' formadminreply ' +cleanid+ ' > ';
inputcontent+=jslang[0]+ "<br/><textarea cols= ' rows= ' 3 ' name= ' adminreplycontent ' id= '" adminreplycontent "+cleanid+" ' ></textarea><br/> ';
inputcontent+= "<input type= ' button ' onclick=\" ajax_adminreply (' "+cleanid+"); return false;\ "value= '" +jslang[1]+ "' class= ' button '/> <input type= ' reset ' value= '" +jslang[2]+ ' ' class= ' button ' /> <input type= ' button ' value= ' +jslang[3]+ ' ' onclick=\ ' hideadminreply (' +divid+ '); \ class= ' button '/> </form> ";
document.getElementById (divID). Innerhtml=inputcontent;
document.getElementById (divid). style.display= ' block ';
}

function Hideadminreply (divid) {
document.getElementById (divid). Innerhtml= ';
document.getElementById (divid). 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);
}
Current 1/2 page 12 Next read the full text

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.