Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding Flash to HTML with Javascript Flashobject

    Hi everyone, I have successfully added Flash to my page but I want the flash animation to be inside the <div id="main">. For some reason when I put the <div id="flashcontent"></div> inside the main div it doesn't show up on the page. Please help. My code is below:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>MikeJamesDesigns</title>
    <link rel="stylesheet" type="text/css" href="cssEdit.css" />

    <script type="text/javascript" src="js/flashobject.js"></script>

    <script type="text/javascript">
    var fo = new FlashObject("bannerISRAEL.swf", "animationName", "450", "60", "8", "#FFFFFF");
    fo.addParam("allowScriptAccess", "sameDomain");
    fo.addParam("quality", "high");
    fo.addParam("scale", "noscale");
    fo.addParam("loop", "true");
    fo.write("flashcontent");

    </script>

    </head>

    <body>

    <!--<div class="tikiImage">
    <img src="/Users/MikeJamesRossi/Desktop/cssEdit/images/tiki.png" alt="tikiTorch" height="1040px" width="1100px"/>
    </div>-->

    <div id="wrapper">

    <div id="sitebranding">
    </div><!--end of sitebranding div-->

    <div id="navigation">
    <a href="home">Home</a> | <a href="about">About</a> | <a href="news">News</a> | <a href="images">Images</a> | <a href="home">Faq</a> | <a href="contact">Contact</a>
    </div><!--end of navigation div-->

    <div id="main">

    <div id="flashcontent"></div>

    </div><!--end of main div-->

    </div><!--end of wrapper div-->

    </body>

    </html>


    My css file looks like this:

    #flashcontent {
    position: relative;
    top: 500px;
    left: 365px;
    width: 60px;
    heightx;
    background-color:red;
    z-index: ;
    }


    Any help would be greatly aprreciated!! Thanks Mike!

  • #2
    Regular Coder oVTech's Avatar
    Join Date
    Nov 2010
    Location
    USA
    Posts
    296
    Thanks
    4
    Thanked 54 Times in 52 Posts
    Quote Originally Posted by rossmiester View Post

    <script type="text/javascript">
    var fo = new FlashObject("bannerISRAEL.swf", "animationName", "450", "60", "8", "#FFFFFF");
    fo.addParam("allowScriptAccess", "sameDomain");
    fo.addParam("quality", "high");
    fo.addParam("scale", "noscale");
    fo.addParam("loop", "true");
    fo.write("flashcontent");
    </script>
    Try to add the script above after the div with id "flashcontent", or else try to wrap it in a window.onload like so:

    Code:
    <script type="text/javascript">
    window.onload = function () {
        var fo = new FlashObject("bannerISRAEL.swf", "animationName", "450", "60", "8", "#FFFFFF");
        fo.addParam("allowScriptAccess", "sameDomain");
        fo.addParam("quality", "high");
        fo.addParam("scale", "noscale");
        fo.addParam("loop", "true");
        fo.write("flashcontent");
    }
    </script>




    I don't know, I don't care, and it doesn't make any difference!
    -Albert Einstein-




  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OMG, I thought I did that before! IT WORKS!! I put the code under the div and now it works.

    How come you have to have the code under the div in order for it to work? I didn't even know that the <script> tag could go in the <body> tag. I always thought that the <script> tag should always be in the <head> tag. Interesting.

    Thanks so much!! I appreciate the help, took me hours trying to figure out why this wasn't working!! Cheers!!

  • #4
    Regular Coder oVTech's Avatar
    Join Date
    Nov 2010
    Location
    USA
    Posts
    296
    Thanks
    4
    Thanked 54 Times in 52 Posts
    Quote Originally Posted by rossmiester View Post

    How come you have to have the code under the div in order for it to work? I didn't even know that the <script> tag could go in the <body> tag. I always thought that the <script> tag should always be in the <head> tag. Interesting.

    You can place script tags in the head and body but that depends on your application. In your case you must place the script under the div because the div where the script is writing to has to be first loaded by the browser.

    Browsers read source-code from top to bottom. When placed in the head, the script tries to use a div that isn't yet loaded in the browser, therefore it fails. Because of this we use the window.onload trick to ensure that the html is loaded before we make any changes to it via a script, but placing the script after the markup works too.




    I don't know, I don't care, and it doesn't make any difference!
    -Albert Einstein-




  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a bunch! Makes total sense!!


  •  

    Posting Permissions

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