Welcome to TalkGraphics.com
Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Apr 2018
    Location
    Barnes, London
    Posts
    947

    Default Auto Refresh IFRAME (external data source) with Javascript

    I am working on a project that can display live data (from Google via a Google Sheet). The iframe correctly refreshes the data when you first load the web page. I would like however to auto-refresh the iframe (not the page) using a time function around 5s.

    It appears there are a myriad of different javascript solutions to fix this, but I would welcome any input that keeps it simple.

    Thanks Gary
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Live Indices.jpg 
Views:	64 
Size:	48.2 KB 
ID:	124601  

  2. #2
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,895

    Default Re: Auto Refresh IFRAME (external data source) with Javascript

    Hi Gary, are you publishing your Google Sheet as a webpage? If you do I find that although any edits aren't instant they update within a few seconds. Is this what you're after?
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  3. #3
    Join Date
    Apr 2018
    Location
    Barnes, London
    Posts
    947

    Default Re: Auto Refresh IFRAME (external data source) with Javascript

    Thanks Egg,

    My Google Sheet updates correctly through the GOOGLEFINANCE api, but right now the web published and embedded versions https://livedata.initiostar.co.uk appear to update only on a browser refresh; not sure why but will sort it out

    Gary

  4. #4
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,895

    Default Re: Auto Refresh IFRAME (external data source) with Javascript

    Interesting. Is your Google sheet getting it's data from other sources?
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  5. #5
    Join Date
    Apr 2018
    Location
    Barnes, London
    Posts
    947

    Default Re: Auto Refresh IFRAME (external data source) with Javascript

    Data is sourced using the Google function (GOOGLEFINANCE); spreadsheet works, the public version updates correctly and will display in a browser, but you have to refresh the browser to see any changes (seems strange but apparently true) e.g. https://docs.google.com/spreadsheets...mIABKu/pubhtml.

    A simple workaround is a refresh button on the web page: https://livedata.initiostar.co.uk. I believe you could have a script added to the iframe to auto refresh a call to the url. I tried <head> <meta http-equiv="refresh" content="10s";> </head> to refresh the page and it works in Xara preview, but not when published (other than in IE). Maybe this is not allowed?

    However, this is not really a Xara issue and I've parked it unless anyone has resolved this type of issue before. The refresh button works

  6. #6
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,747

    Default Re: Auto Refresh IFRAME (external data source) with Javascript

    Quote Originally Posted by Initiostar View Post
    Data is sourced using the Google function (GOOGLEFINANCE); spreadsheet works, the public version updates correctly and will display in a browser, but you have to refresh the browser to see any changes (seems strange but apparently true) e.g. https://docs.google.com/spreadsheets...mIABKu/pubhtml.
    A simple workaround is a refresh button on the web page: https://livedata.initiostar.co.uk. I believe you could have a script added to the iframe to auto refresh a call to the url. I tried <head> <meta http-equiv="refresh" content="10s";> </head> to refresh the page and it works in Xara preview, but not when published (other than in IE). Maybe this is not allowed?
    However, this is not really a Xara issue and I've parked it unless anyone has resolved this type of issue before. The refresh button works
    It will be a cross-domain issue, which browsers block.

    A possible way around is to use a button on the page to load in the URL into the IFRAME.
    You would then need a repeating timer to "click" the same button.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  7. #7
    Join Date
    Apr 2015
    Location
    Germany
    Posts
    927

    Default Re: Auto Refresh IFRAME (external data source) with Javascript

    Hi Acorn!
    Thanks for the work-around, but don't you think your explanation is a little to abstract to a none-coder?

  8. #8
    Join Date
    Apr 2018
    Location
    Barnes, London
    Posts
    947

    Default Re: Auto Refresh IFRAME (external data source) with Javascript

    Thank you to both Acorn & Siran; my coding knowledge is very rusty, dating back to the 70's! I am though trying to grasp some more up-to-date skills from examples at W3 Schools.

    I understand Acorn's suggestion, so I will test these rather rusty skills next week. I would thank Acorn from another post to use an editor rather than just type into Xara's placeholder (welcome Notepad ++); easier than re-ordering a deck of punched paper cards Any suggested code always welcome.

    Gary

  9. #9
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,747

    Default Re: Auto Refresh IFRAME (external data source) with Javascript

    Quote Originally Posted by siran View Post
    Hi Acorn!
    Thanks for the work-around, but don't you think your explanation is a little to abstract to a none-coder?
    siran, I hadn't got to a coding place, just the concept.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  10. #10
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,747

    Default Re: Auto Refresh IFRAME (external data source) with Javascript

    Quote Originally Posted by Initiostar View Post
    Teasier than re-ordering a deck of punched paper cards
    I remember doing that more than once for an ICL1906 at uni!

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

 

 

Bookmarks

Posting Permissions

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