This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Update frame by script
#1
Hi all,

I want to update a frame in my visualization by a script if a new external graph is created.
I found this thread https://forum.logicmachine.net/showthrea...ght=iframe and tried to change it for my case (static url), although I'm new to JavaScript. I created a new group address '1/1/2' and if a 'true' is sent, the frame should be updated. Also I added the additional class 'graph' to my frame. This is the script, but it somehow it only worked yesterday, not now:
Code:
$(function(){
  if (typeof grp != 'undefined') {
    grp.listen('1/1/2', function(object, state) {
      $('.graph').find('iframe').attr('src', 'http://192.168.0.101/Tag1')
    }, true);
  }
});
I also tried to change the datatype of '1/1/2' and the value of it manually, but it didn't update. Is there something wrong with the script or settings of my homeLYnk? Because yesterday it worked.

Best Regards
Reply
#2
Try running code directly in browser console (F12):
Code:
$('.graph').find('iframe').attr('src', 'http://192.168.0.101/Tag1')

Also check that selector is correct (this call should return 1):
Code:
$('.graph').find('iframe').length
Reply
#3
The second call returned 1 and this is the result from call 1, but the frame didn't update:
Code:
$('.graph').find('iframe').attr('src', 'http://192.168.0.101/Tag1')  
{…}
0: <iframe border="0" src="http://192.168.0.101/Tag1" width="1045" height="431" frameborder="0">
context: HTMLDocument http://192.168.0.130/scada-vis/#6
length: 1
prevObject: {…}
 0: <div class="item graph item-iframe" style="top: 336px; left: 0px; z-index: 10; width: 1045px; height: 431px;">
 context: HTMLDocument http://192.168.0.130/scada-vis/#6
 length: 1
 prevObject: Object { 0: HTMLDocument http://192.168.0.130/scada-vis/#6, context: HTMLDocument http://192.168.0.130/scada-vis/#6, length: 1 }
 selector: ".graph"
 __proto__: Object { jquery: "2.2.4", constructor: G(), length: 0, … }
 selector: ".graph iframe"
__proto__: Object { jquery: "2.2.4", constructor: G(), length: 0, … }

Well now it worked again after a while, but I didn't change anything.
I just wanted to check if the script is correct, maybe it's a browser problem. If I discover why it didn't work I'll post it. Thank you anway.
Reply
#4
Do you have "persistent" mode enabled for this frame?
Reply
#5
(18.04.2018, 09:46)admin Wrote: Do you have "persistent" mode enabled for this frame?

I have it not enabled right now, but what would change if it's enabled?
Reply
#6
Without persistent mode iframe is removed from plan once plan is not visible. With persistent mode enabled iframe is only created once.
Reply


Forum Jump: