JavaScript processing page

Source: Internet
Author: User
Tags return string version
Scripting languages such as page 1.javaScript cannot access local files, although local files can be accessed in some HTML pages on the file:///path or file path on this computer, but this is because the same local files are accessible between them!

In XMLHTTP technology, the previous version of MSXML is accessible to local files, because it is also a security vulnerability, there is already a related package or a new version of MSXML, has been prohibited this operation!

The only solution is to upload the files that need to be processed to the server, then return to the client and then be processed by the scripting language.

2. For innerHTML, it is not a string, and the addition of strings is no way to make it a stream of XML characters.

Treatment methods: 1 can be innertext=innerhtml, and then use InnerText to get the character stream, but to the InnerHTML in the "(in the extraction of InnerHTML, he will also" change ") to ' Can!

Example: Var xmlstr=new String (xmlfileinfo.innerhtml);
Xmlfileinfo.innertext= "";
alert (XMLSTR);
Xmlstr= "" +xmlstr+ "";
Xmlstr = Xmlstr.replace (/\ "/g," "");

can also be obtained with the Var str=new String (div.innerhtml).

3. For general marking, such as <span><input>, can usually be marked directly with ID, and then use Idname.attribute to get and manipulate its properties. If marked with name, it is traced down from document to get and manipulate his attributes. The ID is not a duplicate name, otherwise it cannot be obtained

Related Properties! and name can be duplicate, usually the first one.

Note: For IDs, if you are in form, add a layer of formName.idName.attribute to make sense!

4. The validation of some forms is achieved through JavaScript. (Do not use onclick, it does not play a test function)


In page: <form method= "POST" action= "Http://" name= "form" >
<input name= "domain" type= "hidden" value= ""/>
<input name= "code" type= "hidden" value= "0"/>

In the. js file:

function Fcheck () {
if (Fm.user.value = = "" | | fm.code.value== "") {
Window.alert ("Please enter your username?");
Fm.user.focus ();
return false;
return true;

5. When using JavaScript for parameter passing, be aware that:

1 for calls to functions in HTML documents, use the format "fanctionname (' Canshu ')". differs from the general language-passing parameters.

2 for the Declaration of a function, is not a parameter type, directly declare variables: function functionname (Canshu) can be.

This is because it is a weak language, different from the usual programming language.

6. For <a> <div> <span> etc, support events and the application of their style parameters.

example: <script language= "Javascript"
Function selected (i) {
research.researchclass.value= I
if (i==1) { "red"; "Blue";
if (i==2) { "red"; "Blue";
 if (i==3) { "Red" "Blue";

&LT;TD width= "valign=" "Top" bgcolor= "#CCFFFF" > <div align= "center" id= "book" ><strong><font size= "4" ><a ><u> books </u></a></font></strong></div></td>
&LT;TD width= "5" valign= "Top" bgcolor= "#FF0000" ><!--dwlayoutemptycell--> </td>
&LT;TD width= "valign=" "Top" bgcolor= "Blue" color= "Red" > <div align= "center" id= "magazine" ><strong>& Lt;font size= "4" ><a ><u> Journal </u></a></font></strong></div></td>
&LT;TD width= "5" valign= "Top" bgcolor= "#FF0000" ><!--dwlayoutemptycell--> </td>
&LT;TD width= "valign=" "Top" bgcolor= "#CCFFFF" > <div align= "Center" id= "others" ><font size= "4" >< Strong><a ><u> Other </u></a></strong></font></div></td>

Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.