• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Odd jscript problem

I've had this a few times recently on one of my Amazon bots (everything is there when you look at the html but it doesn't exist).



To fix it I've taken to using document.getElementsByClassName("info")[0].innerHTML=""; to fix it with and using the classNames of the element which means your div will need to be

<div id="info" class="info"></div>

equally though a better approach would be

var info=document.getElementById("info");
if (info===null){
info=
document.getElementsByClassName("info")[0];
}
if (info!==null){
info.innerHTML="";
}
 
Cheers eek have a go at that when I 've fixed me curtain rods. Ever had a clue why just one element should not exist and only sometimes? Evil spirits!

Edit
Ah. No didn't fix it but ta anyway eek.
 
Last edited: 11:42
IDIOT!

IDIOT!

Bah. Elsewhere in a tool tip function I was setting innerHTML of the container div to "". Sometimes after refresh I would move the mouse over the tool and trigger it.
 
Last edited: 16:00
Could you possibly have additional elements using the same ID name on the DOM at the time?
 
Could you possibly have additional elements using the same ID name on the DOM at the time?

Don't think so. Think it's all solved now as I said. Initially I used a single box to show tips and details for pins/tracks. Then modified the box to include images relating to pins forgetting I'd used it for the tips.

Names can be a problem. Once lazily used names x and y for position in some interactive games, only for them to stop working in Chrome when Google added undocumented properties x and y.
 
Last edited: 16:51

Advertisers

Back
Top