SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2004
    Posts
    419
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error: character "<" is the first character of a delimiter but occurred as data

    I have tried to validate my page http://jimpix.co.uk/

    But get this error 5 times:
    character "<" is the first character of a delimiter but occurred as data

    But I need the "<" in place in some javascript on the page:

    Code:
    function prev_my_photo() {
    	MyPhotoThingVar--;
    
    	if (MyPhotoThingVar <= 0) {
    		MyPhotoThingVar = 0
    	}
    
    	return MyPhotoThingVar;
    }
    I need to have the javascript on the same page, and not as an include, because the ASP code includes the values it is checking against, so I can't include the javascript, otherwise it won't work.

    Is this something I'll have to live with? I can't replace the "<" with an "&lt;" because then the javascript breaks.

    Thanks

    Jim

  2. #2
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wrap your javascript like this to make it compatible with xhtml:
    Code:
    <script type="text/javascript">
    //<![CDATA[
    
    // rest of your javascript goes here
    
    //]]>
    </script>

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2004
    Posts
    419
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks fredda! That worked a treat.

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bumpyride View Post
    Is this something I'll have to live with? I can't replace the "<" with an "&lt;" because then the javascript breaks.
    Not if you serve your XHTML markup as XHTML. If you're using pretend-XHTML you really should keep all JavaScript in external files, since the content type of the script element differs between HTML4 and XHTML1.
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would you get the following code to validate as xhtml 1.0 strict then?

    <link rel="stylesheet" type="text/css" media="screen" title="User Defined Style" href="<?php echo (!$_COOKIE["sitestyle"])?'default':$_COOKIE["sitestyle"]?>.css" />
    Last edited by Breowulf; Jun 1, 2009 at 13:00. Reason: Not enough clarity

  6. #6
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Remove the title attribute and it should validate fine.
    Code:
    <link rel="stylesheet" type="text/css" media="screen" href="<?php echo (!$_COOKIE["sitestyle"])?'default':$_COOKIE["sitestyle"]?>.css" />

  7. #7
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Fredda

    thank you for replying. Unfortunately, it does not solve the problem. It has something to do with '<' and '>'. as in the javascript problem above.

  8. #8
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What error message to you get when you validate?

  9. #9
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also how does your XHTML code look when you do view source in your browser?

  10. #10
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I get the same error message as the original enquirer had - although his related to JavaScript and not php:

    character "<" is the first character of a delimiter but occurred as data

  11. #11
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fredda View Post
    Remove the title attribute and it should validate fine.
    The title attribute is perfectly fine.

    Quote Originally Posted by Breowulf View Post
    I get the same error message as the original enquirer had - although his related to JavaScript and not php:
    You're not trying to validate the .php file itself, are you? That won't fly. You can only validate the generated HTML or XHTML document.
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •