Forum Discussion
Updating a Webobject
With Javascript you can update and manipulate WebObjects.
Simply stated you replace the source of the WebObject with some other source.
You do need to ensure its a safe source... thus 'https' else you get errors..let newSrc = result[0].url.replace("http://", "https://");
Also you need to make sure you got the proper element selected... here i use a specific 'data-model-id' i checked on publishing. And make sure i got the proper window selected and then change the source to the URL i have. Ofcourse this needs to be publicly available.
I am using an attribute selector ( 'data-model-id' ) because that appears to be the only solid way to select a WebObject by code. Using acc-names as i prefer often, doesnot work.let WebObject = document.querySelector('[data-model-id="6U1OA6sSeOT"] > div > iframe'); gsap.to(WebObject ,{attr:{src:newSrc}});
A trick i using at the moment is setting the data-model-id to a easy recognizable one when the Storyline starts.let myWebObject = document.querySelector('[data-model-id="6U1OA6sSeOT"]');myWebObject .setAttribute("data-model-id", "webO_01");
All this is based on online use ofcourse. Testing now if it works with local folders too...
And it does... so thats nice... sharing the setup.
When publishing this online...you need to put the folders somewhere online and change the URL.
Also when testing this locally...ensure your local url to the path of your folders is correct.
Related Content
- 11 months ago
- 4 months ago