Firefox automatically closing an HTML element too

2020-04-09 17:49发布

Can anyone tell me why Firefox would close a form early by adding a </form>? It closes the form well before the submit button - so the form then won't submit.

The whole code for the form is a bit long to post here. It works fine in Chrome and IE, but Firefox seems to close the form early and removes the later </form>.

The html is being output from PHP. Not sure if this would make a difference?

Editing in firebug doesn't work either. Any ideas appreciated.

Thanks

标签: php html firefox
3条回答
甜甜的少女心
2楼-- · 2020-04-09 18:37

Have you tried using a validator to make sure your code is correct?

You can get Tidy to do the validation for you, or send your code to http://validator.w3.org/

That will tell you pretty quickly if you have some questionable markup that's causing the Firefox behavior.

查看更多
神经病院院长
3楼-- · 2020-04-09 18:41

Can anyone tell me why Firefox would close a form early by adding a ? It closes the form well before the submit button - so the form then won't submit.

This usually happens because you have a construct that should be interpreted as a form end tag or is seriously invalid enough that the browser is recovering from the error badly.

The whole code for the form is a bit long to post here.

No, it isn't (although if you can create a reduced test case that still demonstrates the problem then that would be preferred.

The html is being output from PHP. Not sure if this would make a difference?

It wouldn't. Browsers only care about what is in the HTTP response, not how it got there.

查看更多
我欲成王,谁敢阻挡
4楼-- · 2020-04-09 18:47

When a browser closes a form or div unexpectedly, it's usually because there's some kind of mistake in the code - like a closing div instead of an opening one.

I suggest you feed your code to the w3c Validator, and fix the errors.

查看更多
登录 后发表回答