Common JavaScript records of individuals

Source: Internet
Author: User
/****** DWR is set to synchronize. In the callback function, you can operate the main function variable and set it to asynchronous. Then, you can ***/dwrengine. setasync (false);/****** use the splice (index location, quantity) method to remove the elements in the array ******/options. splice (I, 1);/****** obtain the scroll height of the vertical scroll bar. The horizontal scroll bar is similar to ******/function getscrolltop () {var scrolltop = 0; if(document.documentelement&document.doc umentelement. scrolltop) {scrolltop=document.doc umentelement. scrolltop;} else if (document. body) {scrolltop = document. body. scrolltop;} return scrolltop;}/****** IFRAME height automatically adapts to begin *****/function reinitiframe (_ IFRAME) {var IFRAME = document. getelementbyid (_ IFRAME); try {var bheight = iframe.content+doc ument. body. scrollheight; var dheight = iframe.content?#document.doc umentelement. scrollheight; var Height = math. max (bheight, dheight); IFRAME. height = height;} catch (Ex) {}}< IFRAME id = "frame_edit" name = "_ edit" src = "" scrolling = "no" frameborder = "0" onLoad = "this. height = 100 "width =" 100% "> </iframe> <SCRIPT type =" text/JavaScript "> window. setinterval ("reinitiframe ('frame _ edit')", 200); </SCRIPT>/****** IFRAME automatically adapts to end ******/
Style. display is compatible with the writing methods of IE and ff. Document. getelementbyid ("test "). style. display = "Block"; // iedocument. getelementbyid ("test "). style. display = "table-row"; // compatible Statement of FF: document. getelementbyid ("test "). style. display = document. all? "Block": "table-row"; document. getelementbyid ("test"). style. Display = "";
/* Obtain the value of radio by name */function getradiovalue (rname) {var es = Document. getelementsbyname (rname); If (ES & es! = NULL) {for (VAR I = 0; I <es. length; I ++) {If (ES [I]. checked) return es [I]. value ;}} return NULL ;}// regular expression, matching <SCRIPT> </SCRIPT> var regscript = new Regexp ("<[\ s] *? Script [^>] *?> [\ S] *? <[\ S] *? \/[\ S] *? Script [\ s] *?> "," Gi "); // regular expression, matching <style> </style> var regstyle = new Regexp (" <[\ s] *? Style [^>] *?> [\ S] *? <[\ S] *? \/[\ S] *? Style [\ s] *?> "," Gi "); // regular, match all tags, such as: <p> var reglabel = new Regexp (" <[^>] +> ", "Gi"); // regular expression, matching spaces, line breaks, and other var regspace = new Regexp ("[\ n | \ r |\\ T | & nbsp;] "," Gi ");/* convert HTML to plain text (clear HTML Tag code) */function html2text (value) {If (value =" ") return value; value = value. replace (regscript, ""); value = value. replace (regstyle, ""); value = value. replace (reglabel, ""); value = value. replace (regspace, ""); return value ;}

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.