Reputation: 26326
So I wrote this page from scratch, using php, python and bash. The page collects data from the server, and displays it.
I would like to add tooltips on the world map, such that the user could see the station name on click/mouseover. I followed this tutorial.
1- I wrapped my world image with #wrapper
2- I added the CSS code
3- I added the Javascript code.
This appeared to look fine in the beginning and the tooltip is working, but on Google Chrome, like 90% of the time (I'm on Windows 10 viewing this) I suddenly see that the world map gets messed up, as follows, getting over the data plots:
While it should look like this:
I noticed that this problem happens in Google Chrome, and not on Mozilla Firefox or Microsoft Edge... Why is this happening? I have the feeling that a simple float command could fix it. Could you please help me with this? Why is this happening?
If you require any additional information please ask.
UPDATE:
I noticed removing this part of the script solves the problem:
$('#wrapper').css({'width':$('#wrapper img').width(),
'height':$('#wrapper img').height()
})
But then the tooltip doesn't work.
Upvotes: 0
Views: 185
Reputation: 4050
You have your rome.js
included in head
section. If it will be loaded earlier then html body, it will be executed earlier then dom content loaded.
So the first time evertything works, because js
is loading with dom content. After first refresh js
will be taken from cache and executed too early.
So you should prevent that using jquery $(document).ready()
method or DOMContentLoaded
event.
Or you could simply include your rome.js
in the end of the body
section.
Upvotes: 1