- This topic has 8 replies, 4 voices, and was last updated 20 years, 3 months ago by Scott Anderson.
-
AuthorPosts
-
hayedidMemberI have had the following problem occur in various code. Is seems to be directly associate with the use of <=
For example, within a JavaScript scriptlet, everything from (and including) “= 122” on is in red. *note* the ‘<‘ in ‘<=’ is not in red.
// Capitalize Input and Limit to Alphabetic
if ((event.keyCode >= 97) && (event.keyCode <= 122))
event.keyCode = event.keyCode – 32;
var keyValue = String.fromCharCode(event.keyCode);
regexp = /[a-zA-Z]+/;Thanks,
Hayedid
Riyad KallaMemberHayedid,
Javascript inside of HTML pages should be surrounded with HTML comment blocks: <!– and –>, is this possibly the problem?e.g.
<script> <!-- // code here --> </script>
hayedidMemberOkay. That worked thanks. Someone had told me to leave these out in order to get the colors working properly for JavaScript. I guess that’s not taboo.
Do you know if there is a plugin that will do syntax colorization for JavaScript within an HTML file?
Thanks,
Hayedid.
Riyad KallaMemberHayedid,
We aren’t aware of any editor supporting the Javascript inlined in HTML, but if you want to break your javascript out into JS files that you link to in your page, you can use MyEclipse for the JS editing as it supports javascript stand alone files (hopefully autocomplete will be comming down the road sometime).
hayedidMemberThank you. 😀
paul.lebeauMemberThis is still a bug right – is it down to be fixed?
The HTML comment workaround was originally added to Javascript to deal with early browsers that didn’t recognise the <script> tags. It should not be required any more.
Scott AndersonParticipantPaul,
We had a long thread on this topic here:
https://www.genuitec.com/forums/topic/html-tag-and-javascript-issues-within-the-editor/&highlight=The commenting out of the javascript bodies appears to be required by the HTML spec. If someone can show that it is not, I’ll be more than happy to open a bug report on the item. However, if it is required by the spec as a development tool we really need to show it as an error. Another alternative might be an enhancement request to allow you to choose to relax conformance to the spec in this area.
paul.lebeauMemberTo quote section 6.2 of the HTML 4.0 spec, which I think is fairly explicit:
“Although the STYLE and SCRIPT elements use CDATA for their data model,
for these elements, CDATA must be handled differently by user agents.
Markup and entities must be treated as raw text and passed to the
application as is. The first occurrence of the character sequence “</”
(end-tag open delimiter) is treated as terminating the end of the
element’s content. In valid documents, this would be the end tag for
the element.”And if you look at the examples under the discussion of the <script> tag, they include examples that don’t use the htmll comment trick.
Scott AndersonParticipantPaul,
Interesting. I’ll reopen this item and reference this thread. Thanks!
-
AuthorPosts