Alex&R Posted February 9, 2011 Report Share Posted February 9, 2011 Валидатор в FireFox ругается на JavaScript. Пробовал несколько вариантов, но проблема не решается. <script type="text/javascript"><!--//<![CDATA[код скрипта//]]>--></script>и<script type="text/javascript">/*<![CDATA[*/код скрипта/*]]>*/</script>На сколько можно верить валидатору "огненной лисы"? Quote Link to comment Share on other sites More sharing options...
0 Vlad Posted February 10, 2011 Report Share Posted February 10, 2011 Вы уверены, что валидатор ругается именно на cdata, а не код скрипта? Quote Link to comment Share on other sites More sharing options...
0 Alex&R Posted February 10, 2011 Author Report Share Posted February 10, 2011 Конечно же на код скрипта. Quote Link to comment Share on other sites More sharing options...
0 Vlad Posted February 10, 2011 Report Share Posted February 10, 2011 И где код скрипта? Quote Link to comment Share on other sites More sharing options...
0 Alex&R Posted February 10, 2011 Author Report Share Posted February 10, 2011 <script type="text/javascript" charset="utf-8"><!--//<![CDATA[$(document).ready(function() {$(function(){ $("select#id_city").change(function(){ $.getJSON("{% url area_by_city %}", {city: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].pk + '">' + j[i].name + '</option>'; } $("select#id_area").html(options); }) })})$('#spinner') .hide() // hide it initially .ajaxStart(function() { $(this).show(); }) .ajaxStop(function() { $(this).hide(); })});//]]>--></script>Ругается на эту строку:options += '<option value="' + j[i].pk + '">' + j[i].name + '</option>';а именно на </option>А вот что пишет:Cause:The 2 characters "</" have been detected in a wrong place.Example:In most cases, this is due to wrong java script:Good document.write("</h1>");Good document.write("<\/h1>"); Quote Link to comment Share on other sites More sharing options...
0 Vlad Posted February 10, 2011 Report Share Posted February 10, 2011 Правильно ругается. Что вам мешает сделать по приведенному примеру с <h1>? Quote Link to comment Share on other sites More sharing options...
0 SelenIT Posted February 10, 2011 Report Share Posted February 10, 2011 Только всё-таки второй вариант экранировки (сидата в JS-ных комментах) лучше. Практика HTML-ного коммента в скрипте — наследие темных веков веба, когда не все браузеры вообще понимали скрипты. В XML-режиме этот вариант работать не будет (там парсер тупой — ему сказали коммент, значит, коммент. Quote Link to comment Share on other sites More sharing options...
Question
Alex&R
Валидатор в FireFox ругается на JavaScript. Пробовал несколько вариантов, но проблема не решается.
и
На сколько можно верить валидатору "огненной лисы"?
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.