Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document.body.innerHTML += prevents other scripts from executing #13

Closed
torvista opened this issue May 15, 2016 · 0 comments
Closed

document.body.innerHTML += prevents other scripts from executing #13

torvista opened this issue May 15, 2016 · 0 comments

Comments

@torvista
Copy link
Contributor

torvista commented May 15, 2016

in jscript_imagehover.js, the document.addEventListener clause has been added around the original code:

document.addEventListener("DOMContentLoaded", function (event) { if (document.getElementById || document.all) { document.body.innerHTML += '<div id="trailimageid"></div>'; } });

I found this stopped all my other scripts from working.

Eventually (don't ask how long...) I discover this:
http://stackoverflow.com/questions/5113105/manipulating-innerhtml-removes-the-event-handler-of-a-child-element

I propose this, which (apart from working) should be faster as it does not manipulate the entire dom, and since this script is for the image hover, it doesn't make sense to execute it before the images are loaded, as was the case with using DOMContentLoaded.
window.addEventListener("load", function () { document.body.insertAdjacentHTML('beforeend', '<div id="trailimageid"></div>') });

Why this was not a problem previously is something I cannot justify spending another minute on!

lat9 referenced this issue in lat9/zen_Image-Handler Oct 10, 2017
Per the description given in the issue.
lat9 added a commit that referenced this issue Oct 10, 2017
@lat9 lat9 added this to the v5.0.0 milestone Oct 15, 2017
@lat9 lat9 closed this as completed Nov 10, 2017
torvista pushed a commit to torvista/zen_Image-Handler that referenced this issue Mar 15, 2023
torvista pushed a commit to torvista/zen_Image-Handler that referenced this issue Mar 15, 2023
…ersion-fix

DivaVocals#13 - `imagecopy` float implicit conversion warning
torvista pushed a commit to torvista/zen_Image-Handler that referenced this issue Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants