JS manually specifies the form action-(difficult issue encountered during Seo-1)

Source: Internet
Author: User
The tester just found that an error occurred while submitting data in Firefox,
I checked and found that it was a piece of JS Code The difference between IE and Firefox was not taken into account during writing.
In IE, document. aspnetform. Action is not recognized in Firefox.
After checking some JS information, modify the following:
Original code:
VaR Path = Document. aspnetform. Action;
Document. aspnetform. Action = '/' + path;
Code after modification:
VaR theform = Document. Forms ['aspnetform'];
If (navigator. appname = 'netscape ')
{
VaR act = theform. Action;
VaR inde = act. lastindexof ("/");
VaR Leng = act. length;
VaR filename = act. substring (INDE, Leng );
Theform. Action = 'HTTP: // '+ window. Location. Host + filename;
}
Else if (theform ){
Theform = Document. aspnetform;
VaR Path = theform. Action;
Theform. Action = '/' + path;
}

When debugging JS, we found that the substring method in JS differs from the substring method in C #.

JS substring Method
Function substring (START: Number, end: Number): String
Parameters
Start is required. Index Integer starting from 0, indicating the starting position of the substring.
End is required. An Index Integer starting from 0, indicating the end position of the substring.
Start from start and end.

C # substring Method
Function substring (string startindex, string number)
The number of characters starting with startindex.

The following is a reference --------- good things should be noted down!
Sets or obtains the specified file name or path of an object.
<SCRIPT>
Alert (window. Location. pathname)
</SCRIPT>

Set or retrieve the entire URL as a string.
<SCRIPT>

Alert (window. Location. href );
</SCRIPT>
Set or obtain the port number associated with the URL.
<SCRIPT>
Alert (window. Location. Port)
</SCRIPT>

Set or obtain the protocol section of the URL.
<SCRIPT>
Alert (window. Location. Protocol)
</SCRIPT>

Set or obtain the segment following the # In the href attribute.
<SCRIPT>
Alert (window. Location. Hash)
</SCRIPT>

Set or obtain the hostname and port numbers of the location or URL.
<SCRIPT>
Alert (window. Location. HOST)
</SCRIPT>

Set or obtain the Section following the question mark in the href attribute.
<SCRIPT>
Alert (window. Location. Search)
</SCRIPT>

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.