Skip to content
Advertisement

Why is position set to absolute even though I have explicitly set position to unset?

Making a 3D news web app using javascript – https://shange-fagan.github.io/globe.news/

enter image description here

I am getting the message in the console that the position of my html element is set to absolute even though in the code I have explicitly set it to unset, here is my code:

JavaScript

please let me know what I am doing wrong, not sure if its because the src of my html element has its own styling which I don’t have access to or if I should be using typescript instead of javascript.

edit: here is a screenshot of the element and its parent in the elements tab in the devtools, as you can see the element is contained within a script tag using var my_element = document.createElement(element) and it has to be this way because I need the html element to display on the 3d globe which is using javascript enter image description here enter image description here

2nd edit: screenshot of new errors after implementing suggested code: enter image description here

3rd edit: after fixing the rss news widget embed link it is starting to display but not in the way I want, its displaying the widget above the globe instead of on the globe as is preferred: enter image description here ideally the widget would be hovering over the globe like in these markers example enter image description here

Edit: the basic version is working now but I can’t stop the markers from displaying randomly and not above each country, here is the error I get when I try to replace the random markers with the latitudes and longitudes of each country from a json file: enter image description here here is the code for replacing random markers for markers above each country specifically:

JavaScript

edit: screenshot of working html markers that display news widgets with country locations: enter image description here

enter image description here enter image description here

Advertisement

Answer

Your error

Your error came from globe.gl when you call Globe().htmlElement({} => html) without a valid argument. There are multiple errors in how you created script tags and define the iframe. The style position error is unrelated to your line my_awesome_script.style.position = "unset";.

Using the inspector, variable t shows that you’re returning the iframe as a string ("n...<iframe ...") instead of a valid HTML element. Hence it creates the error on line 37713 when defining style on the element.

enter image description here

Solution

The below edits to your globe object should give you the preferred results. It was based on your index6.html. See comments for detailed explanations

JavaScript

Further reading

Example of globe.gl with HTML DOM element https://globe.gl/example/html-markers/

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement