Copy link to clipboard
Copied
Hi,
I`m using Captivate 9 and publish in HTML5.
If I have a classical project (non-responsive) with a specific size, say 1200 x 800 pixels, is there a way to place an object to some specific absolute x-y-position on the screen using JavaScript? For example if I like to place a SmartShape at x=100 and y=200? (Here, x and y could probably depend on a variable).
I know how to place an object relative to its previous position using JS, seeCaptivate scripting - change x & y position of object
Of course I could use this to calculate the respective absolute position, but sometimes it`s easier just to enter the coordinates. This should be possible with JS without using any widget.
Any help is greatly appreciated!
1 Correct answer
var myObj = document.getElementById("objectName");
myObj.style.left = varX+"px";
myObj.style.top = varY+"px"
Copy link to clipboard
Copied
I'm unclear on what you want here - are you looking to lock an object into place in a master slide layout? The x and y coordinates for any static object on a screen can entered in the properties tab:
Is there something I'm missing in what you want the object to be able to do with regard to the variables you mentioned?
Copy link to clipboard
Copied
Thank you for the answer! But what I need is to position an object with JavaScript. The position of objects (in my projects) often depend on some other variables.
Say I have two variables var_1 and var_2 (maybe depending on text entry by the user or on other things). Now I want to set the object (SmartShape or whatever) on X = var_1 and Y = 3*var_2 (just as an example).
Copy link to clipboard
Copied
var myObj = document.getElementById("objectName");
myObj.style.left = varX+"px";
myObj.style.top = varY+"px"
Copy link to clipboard
Copied
Great! Thank you very much TLC, this worked for me!
Copy link to clipboard
Copied
How do you apply javascript to a text caption? Adding a c does not seem to animate it only the shape of the box animates leaving the text at its location
Copy link to clipboard
Copied
I am a bit lazy concerning JS. In this case I would use the CpExtra widget by InfoSemantics. It has two variables xcmndPosX and xcmndPosY that can be used for what you are asking here. Much easier, less headaches. Have a look:
Copy link to clipboard
Copied
Hi Lilybiri,
my projects had some problems with Edge when I used CpExtra (I think they even say that CpExtra had not been extensively tested with Edge). I want to avoid a widget here as I think positioning of objects should be a standard application for JS.
Copy link to clipboard
Copied
True, was one of the testers, and Edge was still pretty new.
It should be possible with JS, but cannot help more.
Copy link to clipboard
Copied
Hi all,
I am the developer of CpExtra. Since the beta testing phase I know of people who have used CpExtra in the Edge browser without issue. The reason why Edge wasn't supported in the past was because I hadn't access to a computer with the Edge browser and wasn't able to test with it. Now that I do, if someone encounters an issue with CpExtra and Edge they can contact me and I can fix the issue.
So far I know of no outstanding issues with CpExtra and Edge.
Tristan,
Copy link to clipboard
Copied
Thanks Tristan. I didn't have any issues in Edge until now.

