How to Refresh an iFrame and not my whole website.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Stranden

    How to Refresh an iFrame and not my whole website.

    Hello, my name is Martin and I am the owner of www.tot1clan.co m
    as you can see, to the very right on my website is a server status box for my BFBC2 server. I have tried to make only the server status box refresh, but the whole page refreshes for me :/
    So can any of you pro people please edit and post back the correct code for my server status box so that only the box refreshes and not the whole site?

    Thank you :D

    Code:
    <center>
    </style>
    <script LANGUAGE="JScript" >
    window.setInterval(refreshGadget, 50000);
    function refreshGadget() 
    {location.href = location.href;}
    </script>
    </head>
    <p style="text- align: right;">
    <body bgcolor="#000000">
    <iframe src="http://cache.www.gametracker.com/components/html0/?host=85.236.109.61:19667&bgColor=222222&titleBgColor=11111D&borderColor=333333&fontColor=8790AE&titleColor=FFFFFF&linkColor=FF9900&borderLinkColor=999999&showMap=1&showCurrPlayers=0&showTopPlayers=0&showBlogs=0&width=200" frameborder="0" scrolling="no" width="200" height="267"></iframe></body>
    </html>
    </center>
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Give the iframe an ID <iframe id="iFrame" and then access the iframe with document.getEle mentById("iFram e"), then reload the iframe by setting its src to itself. There's another option too, but try this one first.

    Comment

    • Martin Stranden

      #3
      Hi, I'm very sorry, but I didn't understand much of what you just said :P All i have done was to turn a windows 7 gadget into this by removing the top lines. I am very noobish at these stuff, so can you post the finished code or something? That would be VERY handy :D /cheers

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You'd add the code within the refreshGadget() function (line 6 replacing the existing code), e.g. something like:
        Code:
        var iframe = document.getElementById("iFrame");
        iframe.src = iframe.src;
        Note that this may not work depending on your settings, but there's ways round that.

        Comment

        Working...