How to remove an error on the page

How to remove an error on the page

Very often the programmers writing the code of pages of the website forget to check what type of the web browser (Internet Explorer, Mozilla, Opera, etc.) and the version will be used for viewing the website. For faultless page display in all browsers it is necessary to modify those parts of the code of pages where objects or methods, specific to any given web browser, are used. The neglect or ignorance of these principles can lead to the fact that in the bottom of a browser window, in the left part of a status bar, there is an icon - a triangle with the exclamation mark, and the browsed page is displayed and works incorrectly. Several simple recommendations will allow developers to avoid emergence of such errors.

It is required to you

  • Skills of work with the HTML and JavaScript languages.

Instruction

1. First of all it is necessary to install the reason and the place of emergence of an error. For this purpose click a mouse on an icon and in the appeared dialog box click ""Display Details"". After that it will be possible to view the text of an error and the line number of the code of the page where wrong expression - fig. 1 contains. As a rule, it is the errors JavaScript, and they are called by banal errors of coding or the fact that the syntax and the supported functions and objects of this language are different in different web browsers.

2. After acquaintance with the text of an error it is necessary to define whether it is a coding error, or it arises because the used web browser or its current version does not support your JavaScript standard. Understand to what type the error belongs, it is simple - to open enough the page in different browsers. If the error arises everywhere, then it is rather simple to eliminate a coding error. The most widespread errors such - syntax and links to empty (nonexistent) objects or methods.

3. In case the error arises not in all web browsers, it is necessary or to simplify the code, having refused use of the special functions or objects characteristic only of JavaScript of that browser where the page is displayed without error, or to add check on type of the web browser and its version and depending on result to call the corresponding methods or objects or even to use special syntax.
Here JavaScript fragment containing an example of the simplest check on type and the version of the web browser:
if (Request.Browser.Browser == ""IE"" && Request.Browser.Version == ""6.0"")
{
rn_img.Style.Add (""background"", ""url(images/blank.gif)"");
}
else
{
.....
}.

Author: «MirrorInfo» Dream Team


Print