SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Location
    Auckland, NZ
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re-coding EMBED so that it pass the W3C validation

    My site has the following code it. On running the W3C Markup Validation Service I received a whole host of errors pertaining to this code. On further research I discovered that its because I can't use embed in XHTML 1.0 Transitional files.

    Code:
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="<?php echo($width); ?>" height="<?php echo($height); ?>">
    <param name="movie" value="<?php echo JURI::root(); ?>/modules/mod_shoutcastplayer/ffmp3-config.swf" />
    <param name="flashvars" value="url=<?php echo($url); ?>/?lang=auto&amp;codec=<?php echo $codec; ?>&amp;volume=<?php echo $volume; ?>&amp;introurl=<?php echo($introurl); ?><?php if($autostart == 'true'){echo('&amp;autoplay=');echo $autostart;}else if (autostart == 'false'){echo('');};?>&amp;tracking=true&amp;jsevents=false&amp;buffering=5&amp;skin=<?php echo JURI::root(); ?>/modules/mod_shoutcastplayer/<?php echo($skin); ?>.xml&amp;title=<?php echo($name); ?>" />
    <param name="wmode" value="transparent" />
    <param name="allowscriptaccess" value="always" />
    <param name="scale" value="noscale" />
    <embed src="<?php echo JURI::root(); ?>modules/mod_shoutcastplayer/ffmp3-config.swf" flashvars="url=<?php echo($url); ?>/?lang=auto&amp;codec=<?php echo $codec; ?>&amp;volume=<?php echo $volume; ?>&amp;introurl=<?php echo($introurl); ?><?php if($autostart == 'true'){echo('&autoplay='); echo $autostart;} else if (autostart == 'false'){echo('');};?>&amp;tracking=true&amp;jsevents=false&amp;buffering=5&amp;skin=<?php echo JURI::root(); ?>/modules/mod_shoutcastplayer/<?php echo($skin); ?>.xml&amp;title=<?php echo($name); ?>" width="<?php echo($width); ?>" scale="noscale" height="<?php echo($height); ?>" wmode="transparent" allowscriptaccess="always" type="application/x-shockwave-flash" />
    </object>
    http://www.alistapart.com/articles/byebyeembed/ and http://stackoverflow.com/questions/4...-w3c-compliant appear to provide the solution but I can't seem to get the coding right.

    While the original code in question works, I would like it to pass the validation test.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,114
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    There's too much PHP in that code to get a really good look at what you are working with. Can you post the code as it outputs to the browser? (That is, by going to View > Source.)

    The fact that <embed> doesn't validate is not a biggie, really, as all browsers support it anyway. Validation is more a way of checking for any serious errors.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Location
    Auckland, NZ
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I know... just don't like the fact that they are there :-)

    HTML Code:
    <!-- Start Radio Player -->
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" height="46" width="191">
    <param name="movie" value="http://pilgrimpassingthrough.internetlinked.com//modules/mod_shoutcastplayer/ffmp3-config.swf">
    <param name="flashvars" value="url=http://sc2.shoutcaststreaming.us:8000/?lang=auto&amp;codec=mp3&amp;volume=30&amp;introurl=&amp;tracking=true&amp;jsevents=false&amp;buffering=5&amp;skin=http://pilgrimpassingthrough.internetlinked.com//modules/mod_shoutcastplayer/ffmp3-compact.xml&amp;title=B.A.R.">
    <param name="wmode" value="transparent">
    <param name="allowscriptaccess" value="always">
    <param name="scale" value="noscale">
    <embed src="http://pilgrimpassingthrough.internetlinked.com/modules/mod_shoutcastplayer/ffmp3-config.swf" flashvars="url=http://sc2.shoutcaststreaming.us:8000/?lang=auto&amp;codec=mp3&amp;volume=30&amp;introurl=&amp;tracking=true&amp;jsevents=false&amp;buffering=5&amp;skin=http://pilgrimpassingthrough.internetlinked.com//modules/mod_shoutcastplayer/ffmp3-compact.xml&amp;title=B.A.R." scale="noscale" wmode="transparent" allowscriptaccess="always" type="application/x-shockwave-flash" height="46" width="191">
    </object>
    <!-- End Radio Player-->

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,788
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Get rid of the classid attribute from the <object> tag. That will stop the object tag working for IE6 but will allow it to work for all other browsers so that the <embed> tag will then never be referenced and can be removed.

    If you have oone of the rare sites that still have visitors who use IE6 then you can use IE conditional comments and two object tags (one with the classid for IE6 and one without for all other browsers) so as to not need any embed tags.

    The only browser that doesn't recognise the standard object tag without the classid and which would therefore run the embed version if you got rid of the classid and left the rest of the code alone is IE6.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Location
    Auckland, NZ
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face

    Awesome... I have got it to partially work

    HTML Code:
    <!-- Start Radio Player -->
    <object  width="<?php echo($width); ?>" height="<?php echo($height); ?>">
    <param name="movie" value="<?php echo JURI::root(); ?>/modules/mod_shoutcastplayer/ffmp3-config.swf" />
    <param name="flashvars" value="url=<?php echo($url); ?>/?lang=auto&amp;codec=<?php echo $codec; ?>&amp;volume=<?php echo $volume; ?>&amp;introurl=<?php echo($introurl); ?><?php if($autostart == 'true'){echo('&amp;autoplay=');echo $autostart;}else if (autostart == 'false'){echo('');};?>&amp;tracking=true&amp;jsevents=false&amp;buffering=5&amp;skin=<?php echo JURI::root(); ?>/modules/mod_shoutcastplayer/<?php echo($skin); ?>.xml&amp;title=<?php echo($name); ?>" />
    <param name="wmode" value="transparent" />
    <param name="allowscriptaccess" value="always" />
    <param name="scale" value="noscale" />
    <!--[if IE6]><embed src="<?php echo JURI::root(); ?>modules/mod_shoutcastplayer/ffmp3-config.swf" flashvars="url=<?php echo($url); ?>/?lang=auto&amp;codec=<?php echo $codec; ?>&amp;volume=<?php echo $volume; ?>&amp;introurl=<?php echo($introurl); ?><?php if($autostart == 'true'){echo('&autoplay='); echo $autostart;} else if (autostart == 'false'){echo('');};?>&amp;tracking=true&amp;jsevents=false&amp;buffering=5&amp;skin=<?php echo JURI::root(); ?>/modules/mod_shoutcastplayer/<?php echo($skin); ?>.xml&amp;title=<?php echo($name); ?>" width="<?php echo($width); ?>" scale="noscale" height="<?php echo($height); ?>" wmode="transparent" allowscriptaccess="always" type="application/x-shockwave-flash" /><![endif]-->
    </object>
    When I try add the following I get errors again

    HTML Code:
    <!--[if !IE6]><object  width="<?php echo($width); ?>" height="<?php echo($height); ?>"><![endif]-->
    <!--[if IE6]><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="<?php echo($width); ?>" height="<?php echo($height); ?>"><![endif]-->
    The logic feels sound but obviously it's not

  6. #6
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    HTML Code:
    <object <!--[if IE6]>classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"<![endif]--> width="<?php echo($width); ?>" height="<?php echo($height); ?>">
    Try that instead.

    Non-IE browsers just see the IE conditional tags as HTML comments.

    Keep in mind that IE6 usage has fallen by the wayside, so it might not even be necessary to cater to it (unless your visitor demographic indicates otherwise).
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  7. #7
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Location
    Auckland, NZ
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I tried that but the W3C validation then failed again. I agree, I am happy to just ignore IE6 but am interested from a purely academic point of view as to how I would solve this. What is interesting is the the conditional tag works just fine lower down in the code.

  8. #8
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    In #6 it will fail Validation because you cannot have comment delimiters within a tag itself; <p <!-- I am invalid --> >Error!</p> also occurring; <foo<bar> is invalid in HTML you'd have to use the conditional outside of the tag.

    Within #5 it looks like you haven't closed those new OBJECT elements though I would need to see the full parsed code sample including those nested OBJECT preferably after the PHP processor has dealt with the echo and outputted the markup with the variables.

  9. #9
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,189
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Don't mean to jump in so late but why don't you simply use the SWFObject library?

    You could easily construct the array data needed to build the <object> element plus you don't have to worry about the W3C validator as the object won't be embed until the page completely loads.

  10. #10
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    1. Use HTML5.
    2. Use only embed.
    Simon Pieters

  11. #11
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Location
    Auckland, NZ
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by xhtmlcoder View Post
    In #6 it will fail Validation because you cannot have comment delimiters within a tag itself; <p <!-- I am invalid --> >Error!</p> also occurring; <foo<bar> is invalid in HTML you'd have to use the conditional outside of the tag.

    Within #5 it looks like you haven't closed those new OBJECT elements though I would need to see the full parsed code sample including those nested OBJECT preferably after the PHP processor has dealt with the echo and outputted the markup with the variables.
    Here is the original code:
    HTML Code:
    <object <!--[if IE6]>classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"<![endif]--> width="<?php echo($width); ?>" height="<?php echo($height); ?>">
    <param name="movie" value="<?php echo JURI::root(); ?>/modules/mod_shoutcastplayer/ffmp3-config.swf" />
    <param name="flashvars" value="url=<?php echo($url); ?>/?lang=auto&amp;codec=<?php echo $codec; ?>&amp;volume=<?php echo $volume; ?>&amp;introurl=<?php echo($introurl); ?><?php if($autostart == 'true'){echo('&amp;autoplay=');echo $autostart;}else if (autostart == 'false'){echo('');};?>&amp;tracking=true&amp;jsevents=false&amp;buffering=5&amp;skin=<?php echo JURI::root(); ?>/modules/mod_shoutcastplayer/<?php echo($skin); ?>.xml&amp;title=<?php echo($name); ?>" />
    <param name="wmode" value="transparent" />
    <param name="allowscriptaccess" value="always" />
    <param name="scale" value="noscale" />
    <!--[if IE6]><embed src="<?php echo JURI::root(); ?>modules/mod_shoutcastplayer/ffmp3-config.swf" flashvars="url=<?php echo($url); ?>/?lang=auto&amp;codec=<?php echo $codec; ?>&amp;volume=<?php echo $volume; ?>&amp;introurl=<?php echo($introurl); ?><?php if($autostart == 'true'){echo('&autoplay='); echo $autostart;} else if (autostart == 'false'){echo('');};?>&amp;tracking=true&amp;jsevents=false&amp;buffering=5&amp;skin=<?php echo JURI::root(); ?>/modules/mod_shoutcastplayer/<?php echo($skin); ?>.xml&amp;title=<?php echo($name); ?>" width="<?php echo($width); ?>" scale="noscale" height="<?php echo($height); ?>" wmode="transparent" allowscriptaccess="always" type="application/x-shockwave-flash" /><![endif]-->
    </object>
    And here is the passed code:
    HTML Code:
    <!-- Start Radio Player -->
    <object <!--[if IE6]>classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"<![endif]--> width="191" height="46">
    <param name="movie" value="http://pilgrimpassingthrough.internetlinked.com//modules/mod_shoutcastplayer/ffmp3-config.swf" />
    <param name="flashvars" value="url=http://sc2.shoutcaststreaming.us:8000/?lang=auto&amp;codec=mp3&amp;volume=30&amp;introurl=&amp;tracking=true&amp;jsevents=false&amp;buffering=5&amp;skin=http://pilgrimpassingthrough.internetlinked.com//modules/mod_shoutcastplayer/ffmp3-compact.xml&amp;title=B.A.R." />
    <param name="wmode" value="transparent" />
    <param name="allowscriptaccess" value="always" />
    <param name="scale" value="noscale" />
    <!--[if IE6]><embed src="http://pilgrimpassingthrough.internetlinked.com/modules/mod_shoutcastplayer/ffmp3-config.swf" flashvars="url=http://sc2.shoutcaststreaming.us:8000/?lang=auto&amp;codec=mp3&amp;volume=30&amp;introurl=&amp;tracking=true&amp;jsevents=false&amp;buffering=5&amp;skin=http://pilgrimpassingthrough.internetlinked.com//modules/mod_shoutcastplayer/ffmp3-compact.xml&amp;title=B.A.R." width="191" scale="noscale" height="46" wmode="transparent" allowscriptaccess="always" type="application/x-shockwave-flash" /><![endif]-->
    </object>
    <!-- End Radio Player-->
    Don't mean to jump in so late but why don't you simply use the SWFObject library?
    Sorry by I don't understand what you mean.... what I am doing is editing a Joomla plugin so try and correct the code... basically looking at the code and googling solutions; Don't know what the SWFObject library is or how to use it..... that said, it gives me something new to google :-) Thanks

  12. #12
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,189
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    See how the following goes for you, I simply converted your current code to work with the SWFObject library but of course you will need to test it. Before you can test it make sure you download the swfobject.js file from this link and ensure you update the src path in the below script tag to the location on the server.

    PHP Code:
    <span id="swfMovie"></span>
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript">
        var settings = {
            // Path to the SWF file we want to use
            movie      : <?php echo "'" JURI::root() . "/modules/mod_shoutcastplayer/ffmp3-config.swf'"?>,

            // The height and width of the flash file
            height     : parseInt(<?php echo "'$height'"?>),
            width      : parseInt(<?php echo "'$width'"?>),

            // Setup the flashvars
            flashvars  : {
                autoplay    : <?php echo ($autostart === 'true') ? "'true'" "''"?>,
                buffering   : 5,
                codec       : <?php echo "'$codec'"?>,
                introurl    : <?php echo "'$introurl'"?>,
                jsevents    : false,
                lang        : 'auto',
                skin        : <?php echo "'" JURI::root() . "/modules/mod_shoutcastplayer/" $skin ".xml'"?>,
                title       : <?php echo "'$name'"?>,
                tracking    : true,
                url         : <?php echo "'$url'"?>,
                volume      : <?php echo "'$volume'"?>
            },

            // Setup the parameters
            params     : {
                allowscriptaccess : 'always',
                flashvars         : settings.flashvars,
                movie             : settings.movie,
                scale             : 'noscale',
                wmode             : 'transparent'
            },

            // Setup the attributes
            attributes : {}
        };

        swfobject.embedSWF(settings.movie, 'swfMovie', settings.width, settings.height, false, settings.flashvars, settings.params, settings.attributes);
    </script>


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
  •