1 Attachment(s)
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
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?
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 :rolleyes:
Gary
Re: Auto Refresh IFRAME (external data source) with Javascript
Interesting. Is your Google sheet getting it's data from other sources?
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 :D
Re: Auto Refresh IFRAME (external data source) with Javascript
Quote:
Originally Posted by
Initiostar
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 :D
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
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?
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 :eek: Any suggested code always welcome.
Gary
Re: Auto Refresh IFRAME (external data source) with Javascript
Quote:
Originally Posted by
siran
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
Re: Auto Refresh IFRAME (external data source) with Javascript
Quote:
Originally Posted by
Initiostar
Teasier than re-ordering a deck of punched paper cards
I remember doing that more than once for an ICL1906 at uni!
Acorn