Professorval
Professorval

Reputation: 323

Comments before head tag breaks javascript code

I am writing additional javascript code that is being parsed by a PC client that runs in an instance of IE 7.

The original HTML code I am modifying does not have a doctype declaration and html meta tags. Also, the original HTML code has a multiline comment immediately after the opening HTML tag like this:

<html>
       <!-- 
              Some comments 
              Some more comments 
              Some more comments 
       -->
       <head>
       </head>

       <body>
       </body>
</html>

When I add a doctype declaration and meta tags to make the code look like this:

<!DOCTYPE html>
<html>
       <!-- 
              Some comments 
              Some more comments 
              Some more comments 
       -->
       <head>
              <meta name="viewport" content="width=device-width,initial-scale=1">
              <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
       </head>

       <body>
       </body>
</html>

I start to get weird errors like Object doesn't support property or method 'query Selector' when I try DOM manipulation. I understand having comments immediately after the opening html tag may be invalid HTML but I cannot relocate the comments as that causes other parts of the PC client to fail. I have no access to the source code of the PC client and I think it was written in C#.

What can I do?

Upvotes: 1

Views: 85

Answers (1)

Quentin
Quentin

Reputation: 944480

Internet Explorer 7 is exceptionally ancient. It does not support querySelector.

Upvotes: 1

Related Questions