Firefox does not support document.all solutions

Source: Internet
Author: User

/***************************by garcon1986********************************/

Reference section:

Because Firefox does not support document.all-induced problems (and resolution)

It's a big problem to look into a problem in the afternoon.

Symptoms:
The server keeps receiving undefined requests
Almost all of it came from Firefox.
It's natural to think about JavaScript.

And the common JavaScript error is fault tolerance judgment is not enough
Consider browser compatibility support is not enough
But the general JS error does not produce the request
Now the concept of AJAX is very hot (a few years ago called No refresh technology)
Here is a little trick to set up a page with document.idname.src=
It's AJAX, isn't it?

Solve:
Back to the question
After a moment
It's a simple reason.
An IMG src is ' java script:preloadpic () '

Unfortunately, Preloadpic directly used the document.all.
function Preloadpic () {
DOCUMENT.IMGINIT.SRC=IMGURL[0];
if (document.all) {
......
} else {
Thetimer = settimeout ("Preloadpic ()", 50);
}
}

is if (document.all) This steamed bun caused a problem

Firefox does not support document.all
It's obvious that it's been executed here all the time. That's the recursive call to every 0.05s to call itself
Execute is every 0.05s document.imgInit.src will be set to a nonexistent URL (undefined)

So the problem occurs
server-side endless receive http://domain name/undefined request
(omitted 784 words below)

The solution is also very simple do not document.all. :
getElementsByTagName ("*") can get a collection of all elements
Getelemntbyid can get an element by ID
Getelementsbyname can get an element by Name property


My resolution:


Code is used in:

eid=document.all.select1.value; 

to replace it with:

Eid=document.getelementbyid (' Select1 '). Value;

In addition, Siteid=document.myform.select2.value can be replaced by: Siteid=document.getelementbyid (' Select2 '). Value (two methods are available).

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.