Web product browser compatibility issues have you considered it?

Source: Internet
Author: User

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/83/C0/wKiom1d7bYvgWJH6AABwZ0dS-c8528.jpg-wh_500x0-wm_3 -wmp_4-s_2083841031.jpg "title=" 2.jpg "alt=" Wkiom1d7byvgwjh6aabwz0ds-c8528.jpg-wh_50 "/>

In general, dynamic Web pages have to do a lot of work in addition to the server-side code to write client-side code . For example: Data validation before form submission, Carousel of pictures, menu collection, and so on.

Therefore, the client side of the normal execution of the script must also be properly inspected, but there are a wide range of browsers, Java code interpretation is also different, so how to write the most browsers can execute the script is very important, otherwise the cross-platform of the Web page will be greatly compromised.

At present more people use of IE and Firefox, some of the script is not universal, so in the process of writing must pay more attention, so sometimes you have to write the alternative code to increase compatibility.

  For example:

directive: Document.getelementsbyname ("MyID")

Function: Find all elements of id= "MyID" as callback array

Although this instruction can be performed normally on IE, it is useless to Firefox.

Therefore, consider adding the ID of these elements to the additional number x (X for any number), and then using document.getElementById ("myid_x") to save each element one by one in an array after the page is loaded.

  Property: E.innertext

  Function: Access the text content of the element

On IE, you can use E.innertext = "Test text" to specify the content of the element e, but in Firefox, innerText this attribute is not able to use normal.

Fortunately, there is also an attribute innerHTML can be performed in both normal, so use innerHTML instead of innertext as much as possible.

  Parameters:

Description: The cell element for table Tbcell, the row element for table Tbrow

The following script inserts a cell element into the row element, and index is the insertion position

Tbcell =tbrow.insertcell ();//ie performed normally, Firefox no

Tbcell =tbrow.insertcell (index),//ie, Firefox are normal

For programmers who often use client-side scripts to generate dynamically generated elements, it is time-consuming to choose a higher-compatibility script, but at the very least it ensures that most users can display, operate, and reduce many of the problems that derive from compatibility.

This article is from the "first to a cup of Java press yajing" blog, please be sure to keep this source http://maybeone.blog.51cto.com/11734094/1796005

Web product browser compatibility issues have you considered it?

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.