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);
Xmlstr=xmlfileinfo.innertext;
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)
Cases:
In page: <form method= "POST" action= "Http://entry.126.com/cgi/login" name= "form" >
<input name= "domain" type= "hidden" value= "126.com"/>
<input name= "code" type= "hidden" value= "0"/>
</form>
In the. js file:
function Fcheck () {
if (Fm.user.value = = "" | | fm.code.value== "") {
Window.alert ("Please enter your username?");
Fm.user.focus ();
return false;
}
Else
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) {
book.style.color= "red";
Book.style.background= "Blue";
}
Else
{
book.style.color= "BLACK";
book.style.background= "#CCFFFF";
}
if (i==2) {
magazine.style.color= "red";
Magazine.style.background= "Blue";
}
Else
{
magazine.style.color= "BLACK";
magazine.style.background= "#CCFFFF";
}
if (i==3) {
others.style.color= "Red"
others.style.background= "Blue";
}
Else
{
others.style.color= "BLACK";
others.style.background= "#CCFFFF";
}
}
</script>
...
<TD width= "valign=" "Top" bgcolor= "#CCFFFF" > <div align= "center" id= "book" ><strong><font size= "4" ><a ><u> books </u></a></font></strong></div></td>
<TD width= "5" valign= "Top" bgcolor= "#FF0000" ><!--dwlayoutemptycell--> </td>
<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>
<TD width= "5" valign= "Top" bgcolor= "#FF0000" ><!--dwlayoutemptycell--> </td>
<TD width= "valign=" "Top" bgcolor= "#CCFFFF" > <div align= "Center" id= "others" ><font size= "4" >< Strong><a ><u> Other </u></a></strong></font></div></td>