Widget Iframe change URL Dinamycally - 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: Widget Iframe change URL Dinamycally (/showthread.php?tid=805) |
Widget Iframe change URL Dinamycally - adiaz - 24.05.2017 Hello! I have a widget with iframe inside with external URL. I want this URL to be direct link trendlog but I want to change this URL depending of the button pressed. Is this possible? Or do I have to make one widget for each URL? Thanks! RE: Widget Iframe change URL Dinamycally - admin - 24.05.2017 You can do this via Custom JavaScript, change #widget-2 to your widget's id, create buttons as needed and set Additional classes to btn-1, btn-2 and so on. Code: $(function() { RE: Widget Iframe change URL Dinamycally - adiaz - 24.05.2017 Lot of thanks! $(function() { function seturl(url) { $('#widget-2 iframe').prop('src', url); } $('.btn-1').on('vclick', function() { seturl('https://forum.logicmachine.net'); }); $('.btn-2').on('vclick', function() { seturl('http://openrb.com'); }); }); Modified code for my use! Which is the event to trigger On/Off the Widget? RE: Widget Iframe change URL Dinamycally - admin - 24.05.2017 Use this to emulate click on the button that opens/closes widget: Code: $('.widget-btn').trigger('vclick') RE: Widget Iframe change URL Dinamycally - adiaz - 25.05.2017 Thanks Admin!! |