В верх страницы

В низ страницы
Передать $пасибо! нашему сайту


ГлавнаяIT технологии, фото, видеоIT технологии /  W3C validation check error with & in Google maps API

W3C validation check error with & in Google maps API


Ошибка при проверке W3C in Google maps API

  1. Warning Line 939, Column 69: character "&" is the first character of a delimiter but occurred as data
    …ttp://maps.google.com/maps/api/js?sensor=false" + "&" + "callback=initialize1";

    This message may appear in several cases:

    • You tried to include the "<" character in your page: you should escape it as "&lt;"
    • You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&amp;", which is always safe.
    • Another possibility is that you forgot to close quotes in a previous tag.

Попытка замены "&" на "&amp;" не привела к положительному результату (ошибка ушла, но скрипт перестал работать)

Проблему решил применением String.fromCharCode(38);



function loadScript() {   
var script = document.createElement("script");
var ampersand = String.fromCharCode(38);
script.type = "text/javascript";
script.src = "http://maps.google.com/maps/api/js?sensor=false" + ampersand + "callback=initialize1";

Valid XHTML 1.0 Transitional
Copyright © 2020. Hi-Kotlas.ru. Подготовлено © NorthSoft