Improve InfoBox

Hello, I'm trying to improve the InfoBox of my cesium development ( and I'm finding to do something like that where you can see how into the infobox is showed the interpolate number of height of the polyline in each moment. I'm trying to adapt this code to my web, but the problem is that I have no idea about how I can change the infobox because cesium doesn't have any function to modify it, not?

In this moment I'm reading the documentation about the InfoBox but doesn't appear nothing about modify the content. Do you have any idea?


And another question, exist any function in Cesium to show using the console the values of one entity in the Cesium time?

Ok, I found the method to modify the InfoBox of one entity:

entity.description = "Hello";

But I want insert in the description one value of the entity that is changing with the time (the height of extrusion of a polygon). I found the function getValue(time) but, I have no idea about where is declared the variable time in function. Any help?

In my opinion, the documentation of Cesium is very very well, but one example from each function would help all the doubts...

I found this topic about the same problem (!topic/cesium-dev/RstiXJxCBQE ) and I found the example of Hiroshima ( ) I'm trying to improve my Info Box with a script like this:

entity.description = '<script type="text/javascript">document.write("Hello ");</script>';

But it doesn't work. Someone know how put a script into the description? Thanks!


In order to run a script in the infobox, you have to enable scrips to run in the iframe. This is disabled by default for security reasons, in case you don’t know the source of the data populating the infobox.

You can enable scrips with this code:

var iframe = document.getElementsByClassName(‘cesium-infoBox-iframe’)[0];
iframe.setAttribute(‘sandbox’, ‘allow-same-origin allow-scripts allow-popups allow-forms’);

Also, to get the current value of an entity property, you can use .getValue(viewer.clock.currentTime);



var iframe = document.getElementsByClassName(‘cesium-infoBox-iframe’)[0];
iframe.setAttribute(‘sandbox’, ‘allow-same-origin allow-scripts allow-popups allow-forms’);

This method is valid now??

It’s not working for me.

Certainly function is declared.

but onclick in infobox can’t find function.

-Error message-

Uncaught ReferenceError: youtube_popup is not defined

at HTMLInputElement.onclick (about:blank:1)

Can you put together a Sandcastle ( example showing this issue?


This is my simple example.

I declare function that make alert message.

and Add 2 buttons.

1.Sandcastle button, you can see top of window.

2.Entity’s description, there using onclick method for call function.

1 - Work normally.

2 - Nothing response.

Check it please.

Thank you for your support!

I partially find solution.(it’s a trick?)

iframe is another page.

So there are no function declared.

If you want call function from main page to iframe.

Attach ‘parent’ or ‘top’ front of function name.


—Main page----

function message(){





One thing you could do also is (we did this this), just completely get rid of the default info box and then listen for the selectedEntityChanged events within Cesium and show a custom info box using info from the selected entity

Hi David.

That’s a nice tip.

Your advise contribute improving my work’s quality

Thank you!!

Do you think you can provide an code example of what you mean? Thank you.

I tried on this e.g.

It cannot work when i call the function.

The viewer has a selectedEntityChanged event so you can listen for that, undo the default behavior (set viewer.selectedEntity = undefined) and then do your own custom behavior:

Expanding on this a little further…

What he was looking for (I think) was the ability to show a button in the InfoBox and it run his custom JavaScript when clicked. The issue with that is though that, the InfoBox code is run in an iframe and isn’t in the same scope as his other code.

I’m not 100% sure if this is what Omar was suggesting or not but this is what we did with our tool. Using that selectedEntityChanged event, disable the default InfoBox component and watch that event. When an item is selected, show your own custom modal or other component/HTML that is within the same scope and not in the iframe previously mentioned. That way you have complete control over that piece and can style it to do exactly what you want it to do.

Do you mean like this:

dots.forEach(function(dot) {
        position : Cesium.Cartesian3.fromDegrees(dot.lon,,
        point : {
            pixelSize : 7,
            color : Cesium.Color.STEELBLUE,
            outlineColor : Cesium.Color.BLACK,
            outlineWidth : 1.0

viewer.selectedEntityChanged.addEventListener(function(entity) {