Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Want to refresh a window I have first opened using a batch file.

  • 15-02-2014 2:54am
    #1
    Registered Users, Registered Users 2 Posts: 203 ✭✭


    Completely new to batch files but I've been messing around with them today.

    I created a batch file which opens a firefox window.

    However, I cant seem to find any source to tell me how I would be able to refresh this already open tab automatically.

    Essentially I want to run the batch file to open the webpage and then refresh said webpage once after 5 seconds or so.
    @echo off
    
    start chrome -new-window ''www.insertwebpage.com''
    
    timeout /t 1
    
    start chrome -new-window ''www.insertwebpage2.com''
    
    


    PING seems to come up a lot but cant seem to incorporate it correctly.

    Any thoughts? can it be done?


Comments

  • Moderators, Society & Culture Moderators Posts: 17,643 Mod ✭✭✭✭Graham


    Is it your own web page? If it is you could put a piece of Javascript in the page itself to do the refresh.

    If it's not your webpage, you could create a frame set which also contains the webpage you want to display and again us some Javascript to refresh.


  • Registered Users, Registered Users 2 Posts: 203 ✭✭theaaao


    Thanks for your response. No, its not my own website.

    When you say frame set, is this something I can write within the .bat file?

    Probably a stupid question (completely new to this but loving it so far!) , but I am presuming Javscript is different from a batch file?

    Edit: Wait I see that its possible to use javascript from within the .bat file. Is there a code available that will do the refresh, which I can just slot in? Or is it more complicated then this?


  • Moderators, Society & Culture Moderators Posts: 17,643 Mod ✭✭✭✭Graham


    Nope, the frame set is more like a web page.

    http://www.quackit.com/html/examples/frames/

    The frame set would be on your local machine but would would load your target web page in one of the frames.

    Javascript is different from a batch file as it runs in the browser but to simplify the explanation it does have some similarities. Gazillions of examples out there in Googleland

    There are alternative approaches:
    Find a browser extension for auto-refresh. **THIS MIGHT BE THE EASIEST FOR USE WITH YORU BATCH FILE**
    Search google for something like web page auto refresh kiosk mode


  • Registered Users, Registered Users 2 Posts: 203 ✭✭theaaao


    Found some extensions all right but they seem to only activate once prompted meaning even if I run my batch file and open pages, I still have to manually go to them to press the auto refresh feature.

    Looking at how to incorporate javascript now.


  • Registered Users, Registered Users 2 Posts: 7,501 ✭✭✭BrokenArrows


    This is not going to be possible unless the browser you are using has some command which allows you to specify a refresh interval. None do this as far as im aware.

    If you have any C# or VB programming experience you could very quickly create a browser app which takes an argument specifying a refresh interval.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 7,501 ✭✭✭BrokenArrows


    Ive just knocked a quick one together with C# in Visual Studio 2008.

    It takes the parameters of the website and refresh interval in seconds.

    eg. AutoRefresh.exe www.google.com 5

    NOTE: The website shouldn't have http:// in the address. I was lazy in my coding. :)


  • Moderators, Society & Culture Moderators Posts: 17,643 Mod ✭✭✭✭Graham


    Create a local web page with this:[HTML]
    <html>
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    <script type="text/javascript">
    // set your interval in milliseconds
    var reloadInterval = 5000;
    // this will run when the document is fully loaded
    function init() {
    setTimeout('reload()',reloadInterval);
    }
    // this reloads the iframe, and triggers the next reload interval
    function reload() {
    var iframes = document.getElementsByTagName('iframe');
    if (!iframes) return false;
    for(var i=0; i<iframes.length; i++)
    iframes.src = iframes.src;
    setTimeout('reload()',reloadInterval);
    }
    // load the init() function when the page is fully loaded
    window.onload = init;
    </script>
    </head>
    <body>
    <iframe src="http://boards.ie&quot; width="176" height="128" scrolling="no" id="reloader" style="border:0px;padding:0px;margin: 0px 0px 0px 0px;border: 0px 0px 0px 0px" marginwidth="0" marginheight="0" ></iframe>
    </body>
    </html>[/HTML]

    Change http://boards.ie to the page you want to display, change the 5000 ms interval to however many seconds between refreshes x 1000


Advertisement