Trang web này sẽ có chức năng hạn chế trong khi chúng tôi trải qua bảo trì để cải thiện trải nghiệm của bạn. Nếu một bài viết không giải quyết được vấn đề của bạn và bạn muốn đặt câu hỏi, chúng tôi có cộng đồng hỗ trợ của chúng tôi đang chờ để giúp bạn tại @FirefoxSupport trên Twitter và /r/firefox trên Reddit.

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Tìm hiểu thêm

DOM corrupted after innerHTML (using <input id='id' …)

  • 7 trả lời
  • 3 gặp vấn đề này
  • 1 lượt xem
  • Trả lời mới nhất được viết bởi cor-el

more options

I'm on a success function (in javascript) after an ajax call.

1 myFunctionOnSucces(transport){
2 var sDoc = transport.responseText;
3 var oDummy = document.createElement('div');
4 oDummy.innerHTML = sDoc;
5 var here = 'breakpoint';
6 }

Debugging on line 5 I have this on javascript: sDoc: "<form name='form_edit' method='post' action='my-web'> <input type='hidden' name='id' value=> </form> " oDummy: type div.

When looking on his FirstChild property I have: form#[object HTMLInputElement] my-web

If I remove the hidden input on the response text from server, the object FirstChild of oDummy is: form my-web

So in case I have some input with id='id' then the DOM elements added by oDummy corrupt the form element (it puts [object HTMLInputElement] as the form id atribute).

Is there any restriction on the id's attribute value I can use?

It happens on firefox 26 (not in 17). It happens both, linux and windows client.

Thanks a lot.

Jordi

I'm on a success function (in javascript) after an ajax call. 1 myFunctionOnSucces(transport){<br /> 2 var sDoc = transport.responseText;<br /> 3 var oDummy = document.createElement('div');<br /> 4 oDummy.innerHTML = sDoc;<br /> 5 var here = 'breakpoint';<br /> 6 } Debugging on line 5 I have this on javascript: sDoc: "&lt;form name='form_edit' method='post' action='my-web'&gt; &lt;input type='hidden' name='id' value=''&gt; &lt;/form&gt; " oDummy: type div. When looking on his FirstChild property I have: form#[object HTMLInputElement] my-web If I remove the hidden input on the response text from server, the object FirstChild of oDummy is: form my-web So in case I have some input with id='id' then the DOM elements added by oDummy corrupt the form element (it puts [object HTMLInputElement] as the form id atribute). Is there any restriction on the id's attribute value I can use? It happens on firefox 26 (not in 17). It happens both, linux and windows client. Thanks a lot. Jordi

Được chỉnh sửa bởi cor-el vào

Tất cả các câu trả lời (7)

more options

Hi Jordi, as you can see, the forum software doesn't handle code excerpts very well...

Is there any restriction on the id's attribute value I can use?

form_edit is a valid character string for an ID attribute, according to the traditional rules. https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#id

If you want to post code or a list of strings for consideration, and you don't have a demo page online, you may want to use one of these sites:

more options

Thanks jscher2000 for your tip and for your answer.

The problem I have is not related to form id value (form_edit) but with input name value (id).

Is "id" an allowed value for atribute name (or id atribute)?

I have DOM correupted just when I use "id" as a value for name atribute. And I have a lot of code using it (and working until few weeks ago) :-(

more options

Oh, I thought id="id" was just a placeholder for the actual string...

A few versions ago, there was a major change under the covers in how element properties are handled. This could explain why using a global attribute name like id as a value for some other attribute has become a problem in your application.

more options

Thanks a lot jscher2000.

I read the standard and I can't see any restriction about use "id" as a value for atribute name.

So, may be this is a bug for firefox on later versions?

more options

If you feel motivated, you could file a bug for this here: https://bugzilla.mozilla.org/

more options

Thanks a lot!

I'm goning to do it.

more options

Note that you need to test this in a clean profile without using any extensions and possibly only use the built-in web developer tools.

See "Creating a profile":

You may also check this out in a Beta and Aurora nightly build to see if this still happens.