Logic Machine Forum
Update frame by script - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Update frame by script (/showthread.php?tid=1341)



Update frame by script - winamp - 18.04.2018

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/showthread.php?tid=1212&highlight=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


RE: Update frame by script - admin - 18.04.2018

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



RE: Update frame by script - winamp - 18.04.2018

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.


RE: Update frame by script - admin - 18.04.2018

Do you have "persistent" mode enabled for this frame?


RE: Update frame by script - winamp - 18.04.2018

(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?


RE: Update frame by script - admin - 18.04.2018

Without persistent mode iframe is removed from plan once plan is not visible. With persistent mode enabled iframe is only created once.