image size reading problems with firefox javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • johnric
    New Member
    • Aug 2007
    • 3

    image size reading problems with firefox javascript

    I can't seem to get firefox to read the image size in my javascript. It will work in IE and firefox but firefox will not read the image size. Can anyone see the problem in my code? I am new to programming and not very good at it yet.:

    [HTML]<HTML>
    <HEAD>
    <script language="JavaS cript">
    //-- Generate a random number between 0 and max.
    function randomNum(max) {
    var rNum=NaN
    while (isNaN(rNum)) {
    rNum=Math.floor (Math.random()* (max))
    }
    return rNum
    }

    var sound = new Array()
    sound[0]= "banners/ad108s.swf"
    sound[1]= "banners/pattern.swf"
    sound[2]= "banners/math.swf"
    sound[3]= "banners/font.swf"
    sound[4]= "banners/banner.swf"
    sound[5]= "banners/dolchbook.swf"
    sound[6]= "banners/muscle.swf"
    sound[7]= "banners/store.swf"
    sound[8]= "banners/dolch.swf"
    sound[9]= "banners/shoe.swf"
    sound[10]= "banners/music.swf"
    sound[11]= "banners/font.swf"
    sound[12]= "banners/font.swf"
    sound[13]= "banners/math.swf"
    sound[14]= "banners/mathsheet.swf"
    sound[15]= "banners/font.swf"
    sound[16]= "banners/printpicture.sw f"
    sound[17]= "banners/calendar.swf"

    </script>




    </HEAD>
    <BODY >

    <p>

    <script language="JavaS cript">
    soundFile=sound[randomNum(sound .length)]
    //-- Decide whether to use embed or bgsound.

    document.writel n ("<center><OBJE CT classid\='clsid \:D27CDB6E\-AE6D\-11cf\-96B8\-444553540000'" +

    "codebase\='htt p:\/\/download\.macro media\.com\/pub\/shockwave\/cabs\/flash\/swflash\.cab\#v ersion\=5,0,0,0 '"+
    "WIDTH=500 HEIGHT=90><PARA M NAME\=movie VALUE\="+soundF ile+">"+
    "<PARAM NAME\=quality VALUE\=high> <PARAM NAME\=bgcolor VALUE\=\#000000 >"+
    "<EMBED src\= "+soundFile +" quality\=high bgcolor\=\#0000 00"+
    "WIDTH" + "=" + "500 HEIGHT " + "=" + "90 TYPE\='applicat ion\/x-shockwave-flash'"+
    "PLUGINSPAGE\=' http:\/\/www.macromedia. com\/shockwave\/download\/index.cgi?P1_Pr od_Version\=Sho ckwaveFlash'>"+
    "</EMBED></OBJECT></center>")



    </script>[/HTML]


    Thanks for your help!
    Last edited by gits; Aug 31 '07, 01:40 PM. Reason: added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN!

    That looks like code to play sound. Where's the code that checks the image size?

    Is the image a local image?

    Comment

    • johnric
      New Member
      • Aug 2007
      • 3

      #3
      The variable is called soundFile as I copied some code from a sound javascript but it refers to the array above and randomly selects one of the .swf flash files. It is the width and height tags that are not being read in the javascript document.write.
      Would you know why firefox will not read these tags.
      Thanks,
      John

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        That code is trying to set the width and height to 500 and 90 respectively. Try adding some units, e.g. "px".

        Comment

        • johnric
          New Member
          • Aug 2007
          • 3

          #5
          I tried adding px to the height and width but it didn't work.
          Thanks for the idea though.
          You can see the code working at http://www.netrover.co m/~kingskid/108_05janflash1 .html

          Comment

          • drhowarddrfine
            Recognized Expert Expert
            • Sep 2006
            • 7434

            #6
            You have 20 html errors and I'm guessing the missing end tags might be messing up the DOM tree. Also, your doctype is incomplete putting IE into 'quirks mode'.

            In addition, this is incorrect:
            <script language="JavaS cript">

            It should be <script type="text/javascript">

            Comment

            Working...