Click on Jpg - Get Flash Video loading?

Discussion in 'HTML & Website Design' started by misohoni, Jun 18, 2010.

  1. #1
    I've seen it on some sites where an image is displayed, then when you click on the image...it loads a flv video in it's place...how to do this?

    Thanks guys
     
    misohoni, Jun 18, 2010 IP
  2. godric

    godric Active Member

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    93
    #2
    You can put your image inside a div, and then, using javascript, substitute the content of that div with the flv video code.

    For example:

    <div class="container">
    <div class="first">Hello</div>
    </div>

    Using jQuery, you can replace the content of the div ".first" :

    <script>
    $(".first").click(function () {
    $(this).replaceWith("Bye");
    });
    </script>

    And it will change into:

    <div class="container">
    <div class="first">Bye</div>
    </div>
     
    godric, Jun 18, 2010 IP
  3. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #3
    Thanks but is pretty complex to put all in the ("...") section?
     
    misohoni, Jun 18, 2010 IP
  4. godric

    godric Active Member

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    93
    #4
    Sorry, what section?
     
    godric, Jun 18, 2010 IP
  5. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #5
    This bit: $(this).replaceWith("Bye");


    Instead of Bye I'd need to insert the row of flash code?
     
    misohoni, Jun 18, 2010 IP
  6. godric

    godric Active Member

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    93
    #6
    Yes, you could pass it through a variable:

    var cont = '<object width="480" height="385">...</object>';
    $(this).replaceWith(cont);

    I'm sure there is a better way to do that, but I think it'll do the job.
     
    godric, Jun 18, 2010 IP
  7. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Use SWFobject.

    <script type="text/javascript">
    function c(){
    var so = new SWFObject('http://google.com/movie.swf','player','480','640','9');
    so.addParam('allowfullscreen','true');
    so.addParam('allowscriptaccess','always');
    so.write('player');
    }
    </script>
    <div id="player"><img src="img" alt="" id="pswf" onclick="c();" /></div>
     
    krsix, Jun 18, 2010 IP