{"id":1587,"date":"2016-04-05T01:29:41","date_gmt":"2016-04-05T01:29:41","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=1587"},"modified":"2016-04-05T01:31:49","modified_gmt":"2016-04-05T01:31:49","slug":"cesium-how-to-enable-javascript-in-infobox","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2016\/04\/cesium-how-to-enable-javascript-in-infobox\/","title":{"rendered":"cesium &#8211; How to enable javascript in InfoBox ?"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2015\/10\/phpmind-cesiumjs-show-name.png\" alt=\"phpmind-cesiumjs-show-name\" width=\"440\" height=\"384\" class=\"aligncenter size-full wp-image-1451\" srcset=\"https:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2015\/10\/phpmind-cesiumjs-show-name.png 440w, https:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2015\/10\/phpmind-cesiumjs-show-name-300x262.png 300w\" sizes=\"auto, (max-width: 440px) 100vw, 440px\" \/><\/p>\n<p>The InfoBox does indeed run in an iframe for security and sanitation purposes.  You can remove all restrictions by calling the below line of code after creating the view:<\/p>\n<pre>\r\nviewer.infoBox.frame.removeAttribute('sandbox');\r\n<\/pre>\n<p>Only do this if you are in complete control of the data that will be loaded into the InfoBox, otherwise it is a security issue.<\/p>\n<p>You can style the infoBox just as easy by injecting any css you want into the viewer.infoBox.frame  for example:<\/p>\n<pre>\r\n            var cssLink = frameDocument.createElement(\"link\");\r\n            cssLink.href = buildModuleUrl('Path\/To\/Your\/CSS\/File.css');\r\n            cssLink.rel = \"stylesheet\";\r\n            cssLink.type = \"text\/css\";\r\n            viewer.infoBox.frame.contentDocument.head.appendChild(cssLink);\r\n\r\n<\/pre>\n<p>By default, we inject the contents of Widgets\/InfoBox\/InfoBoxDescription.css<\/p>\n<p>You can also style outer InfoBox properties by overriding the CSS classes defined in  Widgets\/InfoBox\/InfoBox.css in your own apps css file. I&#8217;m not sure if you&#8217;ll be able to add draggable support in this way, but you can do a bunch of other stuff.<\/p>\n<p>If you want to replace the infoBox completely, then simply pass &#8220;infoBox: false&#8221; to the Viewer constructor.  It&#8217;s then up to you to bring up your own widget when an entity is selected.  The InfoBox simply displayed the content of the entity.description property.  You could copy\/paste the existing InfoBox code as a starting point.<\/p>\n<p>http:\/\/www.html5rocks.com\/en\/tutorials\/security\/sandboxed-iframes\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The InfoBox does indeed run in an iframe for security and sanitation purposes. You can remove all restrictions by calling the below line of code after creating the view: viewer.infoBox.frame.removeAttribute(&#8216;sandbox&#8217;); Only do this if you are in complete control of the data that will be loaded into the InfoBox, otherwise it is a security issue. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[53],"tags":[],"class_list":["post-1587","post","type-post","status-publish","format-standard","hentry","category-cesiumjs"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1587","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/comments?post=1587"}],"version-history":[{"count":3,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1587\/revisions"}],"predecessor-version":[{"id":1590,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1587\/revisions\/1590"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=1587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=1587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=1587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}