facebook

Problem with <= inside JavaScript

  1. MyEclipse Archived
  2.  > 
  3. Bugs
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #209516 Reply

    hayedid
    Member

    I 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

    #209520 Reply

    Riyad Kalla
    Member

    Hayedid,
    Javascript inside of HTML pages should be surrounded with HTML comment blocks: <!– and –>, is this possibly the problem?

    e.g.

    
    <script>
      <!--
        // code here
      -->
    </script>
    
    #209553 Reply

    hayedid
    Member

    Okay. 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.

    #209559 Reply

    Riyad Kalla
    Member

    Hayedid,
    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).

    #209588 Reply

    hayedid
    Member

    Thank you. 😀

    #209734 Reply

    paul.lebeau
    Member

    This 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.

    #209736 Reply

    Scott Anderson
    Participant

    Paul,

    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.

    #209984 Reply

    paul.lebeau
    Member

    To 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.

    #210066 Reply

    Scott Anderson
    Participant

    Paul,

    Interesting. I’ll reopen this item and reference this thread. Thanks!

Viewing 9 posts - 1 through 9 (of 9 total)
Reply To: Problem with <= inside JavaScript

You must be logged in to post in the forum log in