Javascript Iframe Refresh Issue with Firefox....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mediagulch
    New Member
    • Jun 2007
    • 4

    Javascript Iframe Refresh Issue with Firefox....

    Hello,

    We are currently running banner ads on a few of our sites and we implemented a javascript so they refresh after every 20 seconds. The script works great in IE though in Firefox it doesn't work at all. We have included the script below and would appreciate any feedback possible.

    Code:
    <script type="text/javascript">
    
    var milliSecondsToWait = 20000;
    
    function reloadIFrame(){
    document.frames['iFrameName'].location.href =
    "http://newt1.adultadworld.com/jsc/z5/ff2 .html?n=607;c=2445;s=271;d=14;w=728;h=90;p=271"
    myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
    }
    var myVar = setTimeout("reloadIFrame()",milliSecondsToWait);
    
    </script>
    The code that we are using in the body of the our pages is:
    Code:
                    <td width="729" height="90" valign="top"> <script language="javascript">
    		  document.write('<iframe id="iFrameName" src="http://newt1.adultadworld.com/jsc/z5/ff2 .html?n=607;c=2445;s=271;d=14;w=728;h=90;p=271" frameborder=0 marginheight=0 marginwidth=0 scrolling="no" allowTransparency="true" width=728 height=90></iframe>');
    		  </script></td>
    Again we appreciate any help in advance and wish we knew more about javascript to not have to bother anyone who is already doing an awesome job helping some many other people.

    Have a great day.

    Mediagulch
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Moved to Javascript forum

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Add name="iFrameNam e" to the iframe.

      Comment

      • ronnil
        Recognized Expert New Member
        • Jun 2007
        • 134

        #4
        Originally posted by acoder
        Add name="iFrameNam e" to the iframe.
        either that or change "frames['iFrameName']" to getElementById( 'iFrameName')

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Originally posted by ronnil
          either that or change "frames['iFrameName']" to getElementById( 'iFrameName')
          yes, and that too... :)

          Comment

          • mediagulch
            New Member
            • Jun 2007
            • 4

            #6
            Originally posted by acoder
            Add name="iFrameNam e" to the iframe.
            Thanks for the feedback on this and when I changed the code to:

            [CODE=javascript]<td width="729" height="90" valign="top"> <script language="javas cript">
            document.write( '<iframe name="iFrameNam e" id="iFrameName " src="http://newt1.adultadwo rld.com/jsc/z5/ff2 .html?n=607;c=2 445;s=271;d=14; w=728;h=90;p=27 1" frameborder=0 marginheight=0 marginwidth=0 scrolling="no" allowTransparen cy="true" width=728 height=90></iframe>');
            </script></td>[/CODE]

            Firefox still doesn't seem to be refreshing the frame. Did I do this correctly?

            Also tried the other version of modifying the javascript to the following:

            [CODE=javascript]<script type="text/javascript">

            var milliSecondsToW ait = 20000;

            function reloadIFrame(){
            document.getEle mentById('iFram eName').locatio n .href="http://newt1.adultadwo rld.com/jsc/z5/ff2.html? n=607;c=2445;s= 271;d=14;w=728; h=90;p=271"
            myVar = setTimeout("rel oadIFrame()",mi lliSecondsToWai t);
            }
            var myVar = setTimeout("rel oadIFrame()",mi lliSecondsToWai t);

            </script>
            [/CODE]

            This was also unsuccessful for me, I am thinking that I am doing something wrong here.

            Any additional feedback would be awesome and thank you again for the help alreay.

            MEDIAGULCH

            Comment

            • ronnil
              Recognized Expert New Member
              • Jun 2007
              • 134

              #7
              do you get any error message from firefox? (go to Tools>Error Console)

              Comment

              • mediagulch
                New Member
                • Jun 2007
                • 4

                #8
                Originally posted by ronnil
                do you get any error message from firefox? (go to Tools>Error Console)
                Hi Ronnil,

                Yes I do get an error code from Firefox and it is:

                Error: document.getEle mentById("iFram eName").locatio n has no properties
                Source File: file:///c:/dev/web/pages/TMP7q0g9kb8jp.h tm
                Line: 15

                Hope that helps and how can we fix this?

                Comment

                • ronnil
                  Recognized Expert New Member
                  • Jun 2007
                  • 134

                  #9
                  try removing the .href so it becomes

                  document.getEle mentById('iFram eName').locatio n = 'yoururl';

                  Comment

                  • mediagulch
                    New Member
                    • Jun 2007
                    • 4

                    #10
                    Originally posted by ronnil
                    try removing the .href so it becomes

                    document.getEle mentById('iFram eName').locatio n = 'yoururl';
                    Removed the .href and no longer seeing the errors, though the iframe doesn't appear to be freshing. So the code now looks like this:

                    [CODE=javascript]<script type="text/javascript">

                    var milliSecondsToW ait = 20000;

                    function reloadIFrame(){
                    document.getEle mentById('iFram eName').locatio n = "http://newt1.adultadwo rld.com/jsc/z5/ff2 .html?n=607;c=2 445;s=271;d=14; w=728;h=90;p=27 1"
                    myVar = setTimeout("rel oadIFrame()",mi lliSecondsToWai t);
                    }
                    var myVar = setTimeout("rel oadIFrame()",mi lliSecondsToWai t);

                    </script> [/CODE]

                    Any ideas?

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      See this link.

                      Either access as part of the frames array and use location.href or as an object and use the src property.

                      Comment

                      • rohitchawla
                        New Member
                        • Jul 2007
                        • 85

                        #12
                        hi
                        i also seem to have same problem
                        when i use

                        document.getEle mentById("myif" ).src=my new url

                        it works fine in IE
                        but dont do anything in firefox or netscape or opera

                        i have the iframe hidden and when i load the url in document.getEle mentById("myif" ).src i also do document.getEle mentById("myif" ).visibility="v isible"

                        Comment

                        Working...