A good one that can detect multiple browser functions and other functions page 1/2

Source: Internet
Author: User

// Examine the browser checks the browser's Function
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 ('compute') =-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 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 = '66' rows = '3' name = 'adminreplycontent' id = 'adminreplycontent" + cleanid + "'> </textarea> <br/> ";
Inputcontent + = "<input type = 'button 'onclick = \" ajax_adminreply ('"+ cleanid +"'); return false; \ "value = '" + jslang [1] + "'class = 'click'/> <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 = '66' rows = '3' name = 'adminreplycontent' id = 'adminreplycontent" + cleanid + "'> </textarea> <br/> ";
Inputcontent + = "<input type = 'button 'onclick = \" ajax_adminreply ('"+ cleanid +"'); return false; \ "value = '" + jslang [1] + "'class = 'click'/> <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 _ properties'). 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 );
}

Related Article

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.