Using javascript to open a web object

Hi,

I have been trying to use similar code from this thread to open a web object but am having no luck.

https://community.articulate.com/discussions/articulate-storyline/webobject-and-storyline-variable

This is how the javascript call is now:

var player=GetPlayer();

var customURL="http://markgretzinger.com/_TEMP/test.html"

OpenWebObject(1,customURL,0,0,720,540,245,52);

I have it staged here: http://markgretzinger.com/_VIA/test/story.html

Can anyone help me? What am I doing wrong?

7 Replies
Marco Faust

Small item - your code is missing a semi-colon after the var customURL line, but that probably isn't the problem.  I mention it, because it is in the version I have built that "works".

The main item:  I suspect that the problem here is that you are using a piece of code that Articulate wants the player to use, but not us.   In the OpenWebObject code, it makes the zindex of the newly created object = -1.  That means it is creating the object and placing it behind the player.  I had to change the code in the story.js file to put the zindex to a positive value (I set it to 900 to make sure) greater than that of the player itself.  Then the object appeared over the player.

I suspect that when this code is used by the player itself, it then goes and shows it when appropriate by increasing the zindex to something that the player determines is correct for the situation that exists at the time it is presented.

So the complete solution is to append a couple lines of code to the bottom of your script to set the zindex of your new object to where it can be seen:

var player=GetPlayer();
var customURL="http://markgretzinger.com/_TEMP/test.html";
OpenWebObject(1,customURL,0,0,720,540,245,52);
var oWebObject = g_oWebObjects["1"];
oWebObject.Div.style.zIndex = "900";

Since you gave your object the id of 1, this calls that object and sets its zindex to 900.  If you want to add many objects this code works.  It is placing your object on the page twice, with the second offset 50 pixels in the x and y directions.

var player=GetPlayer();
var customURL1="http://markgretzinger.com/_TEMP/test.html";
var obj1id = 1;
var obj1zindex = 900;
OpenWebObject(obj1id,customURL1,0,0,720,540,245,52);
var oWebObject1 = g_oWebObjects[obj1id];
oWebObject1.Div.style.zIndex = obj1zindex ;

var customURL2="http://markgretzinger.com/_TEMP/test.html";
var obj2id = 2;
var obj2zindex = 902;
OpenWebObject(obj2id,customURL2,50,50,720,540,245,52);
var oWebObject2 = g_oWebObjects[obj2id];
oWebObject2.Div.style.zIndex = obj2zindex ;

 

 

Christian deTorres

When I do this, the WebObject stays open, even when I change slides. Also, if I click on it, and then click the slide background, the WebObject disappears.

Does anyone know a way around this?

I tried to put a hotspot over the JavaScript-triggered WebObject, but it doesn't seem to work, even when I set the zIndex of the WebObject to "1".