Forum Discussion
Opening a Web Object with JavaScript in HTML5
I need to open a web object with JavaScript because I need to construct the URL for the web object based on information I'll retrieve, so I'll use JavaScript to glue together the final URL and then use JavaScript to launch the web object since you can't use variables in the simple Insert Web Object feature.
Attached is a bare-bones instance of opening a web object with JavaScript. When you publish it, it works; You see the Articulate logo in the player, but only when viewing in a browser that uses Flash. Here is the JavaScript:
var player = GetPlayer();
var logourl="https://www.articulate.com/images/logos/articulate-nav.png";
OpenWebObject(999,logourl,100,100,300,100,200,80);
var oWebObject = g_oWebObjects["999"];
oWebObject.Div.style.zIndex = "900";
I got the 3rd line from this post: https://community.articulate.com/discussions/articulate-storyline/webobject-and-storyline-variable
I got lines 4 & 5 from this post: https://community.articulate.com/discussions/articulate-storyline/using-javascript-to-open-a-web-object (You can't see it if you don't change the zIndex.)
As the first post above says, it doesn't work in HTML5, and later in that post a method is suggested but I can't figure out how to make it work. Since that post has a couple of different tangents in it and is a bit old, I thought I'd start fresh.
Thanks in advance for looking and considering suggesting a solution on how to open a Web Object using JavaScript and have it work in HTML5.
- ChristiePollickCommunity Member
Hi, David -- Thanks for reaching out with your question, and I will need to defer to the JS gurus here in the community to assist, as JS is not something for which we can provide support. Please also feel free to take a look at this sheet on Best Practices if you have not already. :)
- DavidKelling1Community Member
Can Articulate at least give me some hints? I've seen multiple posts about how JavaScript is handled differently, by Storyline, between Flash and HTML5 output. Some insight into what that means might be helpful.
- ChristiePollickCommunity Member
Hi, David -- Here is some additional information that you may find useful: Comparing Flash, HTML5, and Articulate Mobile Player Output for Articulate Storyline 2, and also perhaps this thread on a similar topic, Different javascript behavior in Chrome, depending on Flash or HTML5 output. Hopefully that helps, and others are also welcome to chime in with their ideas and opinions. :)
- JacquiDyachCommunity Member
I have posted an HTML5 solution in the first post you mention above:
Now I'm trying to get it to work in both HTML5 and Flash for the same project. Will update if I find out how!
Thanks Jacqui :) That could certainly assist others in the future.
- RyanBrown-62e7eCommunity Member
Hello I was not sure if I should create a new post but, after searching, this was somewhat related to what I want to do. I have a course with a web object linked to an intranet page that works fine but I would like to see if I can use JavaScript to resize the internet content that is being displayed in the webobject. If it is being displayed at 100% I would like to scale it down to about 75%. Any thoughts on how I can do this using JavaScript? It goes without saying, HTML5 functionality is a must at this point.
- LNoelJeffersonCommunity Member
I realize it has been some time since this last post, however, I'm still trying to get the above code to work. I've downloaded the above storyfile which works perfectly, until you change the URL to something else. I've tried a number of different urls, but I'm not getting any of them to open. I can't even get https://www.articulate.com to open.
Ultimately, what I'm wanting to do is create a url by passing a a variable.
https://lab4.nog-oc.org/Variable1@netops.org/
I've tried everything with no luck. Anyone have any thoughts?
LaRhonda