Skip to content

HTML parsing error : problem based learning

Marie-Louise edited this page Mar 20, 2019 · 2 revisions

one example if the errors that I'm dealing with is regarding the fb pixel which has the link in the head (inside an img tag which is illegal)

Facebook Pixel for developers

https://www.facebook.com/tr?id=1847964762183911&ev=PageView&noscript=1

this is used for analytics...

this code...

drupal_add_html_head($script, 'script');
  $meta = [
    '#theme' => 'html_tag',
    '#tag' => 'img',
    '#attributes' => [
      'height' => '1',
      'width' => '1',
      'style' => 'display:none',
      'src' => 'https://www.facebook.com/tr?id=1847964762183911&ev=PageView&noscript=1',
    ]
  ];
  $fB_pixel_noscript = [
    '#theme' => 'html_tag',
    '#tag' => 'noscript',
    '#value' => drupal_render($meta),
    '#weight' => '100'
  ];

produces this html ...

<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1847964762183911&amp;ev=PageView&amp;noscript=1" /></noscript>

and produces the following error...

Error: Bad start tag in img in head.

Clone this wiki locally