SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Sesame Street Iimitk's Avatar
    Join Date
    Feb 2006
    Posts
    662
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Facebook code validation problem

    Hello,

    I was trying to incorporate Facebook's "Share It" JavaScript code snippet an XHTML 1.0 Strict page, but unfortunately it invalidated the page. The JS code snippet is:

    Code javascript:
    <script>
         function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}
    </script>
         <a href="http://www.facebook.com/share.php?u=url-goes-here>" onclick="return fbs_click()" target="_blank">Share It on Facebook</a>

    This generates 3 validation errors in a Strict doctype:
    1. A missing type="text/javascript" on the script element.
    2. Attribute target not supported in XHTML 1.0 Strict.
    3. And some complicated error messages mainly because of the &t JS code.
    I fixed #1 of course, but failed to deal with 2 & 3. How can I trigger opening new windows with the same size & properties that are set in the JS code without using the target attribute?

    Also I tried to fix the other errors by replacing &t with &amp;t but then again the window doesn't open with the specific dimensions & properties. I also tried to put the whole JS code between /*<![CDATA[*/ and /*]]>*/ which does caused the page to validate but again the JS code to break!

    Any help?
    Imagination is more important than knowledge. - Einstein

  2. #2
    Google Engineer polvero's Avatar
    Join Date
    Oct 2003
    Location
    Mountain View
    Posts
    567
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for the second one, you could simply add more to the onclick that does a window.open, leaving out any parameters like width and height. It will then behave just like target="_blank"

  3. #3
    Sesame Street Iimitk's Avatar
    Join Date
    Feb 2006
    Posts
    662
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by polvero View Post
    for the second one...
    Thanks, but I would expect more from a JavaScript guru.
    Imagination is more important than knowledge. - Einstein

  4. #4
    Sesame Street Iimitk's Avatar
    Join Date
    Feb 2006
    Posts
    662
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's really sad that the JavaScript forum is almost dead albeit all the JS gurus lurking around.
    Imagination is more important than knowledge. - Einstein

  5. #5
    SitePoint Enthusiast SoMBrA's Avatar
    Join Date
    Oct 2007
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To get around with the 1st one:
    <script type="text/javascript">
    your code goes here
    </script>
    The 2nd one as polvero said, you should not use target=_blank.

    For the 3rd one i think that maybe if you fix the script text setting it to text/javascript might work, check it out!


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
  •