Solved

New button/HTML-Object-ID

I always need the HTML object ID of the individual objects (text, image, etc.). So that I don't have to enter the object ID manually in JavaScript every time (especially the correct one :-)), I would like to have another button in Lectora that copies the HTML object ID. This would allow me to paste it with Ctrl+V, for example. Perhaps such a button would be useful here (see screenshot)?

Thanks.

Best wishes

ekmud


Solution

Using the HTML object id directly is not a good idea, it causes portability issues.


Instead create a known name you can reference in JavaScript.


To do this add an On Page Show Action to the Object of type Run JavaScript


Add this JavaScript:

myTop.myButton = %HTMLNAME%;


Where myButton is a name you pick to represent the object.


Then you can use myTop.myButton in your scripts without having to worry about the HTMLNAME changing if you ever copy this to another project.


Hope this helps.



Discussion (3)

Using the HTML object id directly is not a good idea, it causes portability issues.


Instead create a known name you can reference in JavaScript.


To do this add an On Page Show Action to the Object of type Run JavaScript


Add this JavaScript:

myTop.myButton = %HTMLNAME%;


Where myButton is a name you pick to represent the object.


Then you can use myTop.myButton in your scripts without having to worry about the HTMLNAME changing if you ever copy this to another project.


Hope this helps.



What does myTop mean in this connection?

Additionally, if you click that button you highlighted, it brings up the description dialog. From the dialog you can select and copy the html name. If you would rather go that route.