
[英]javascript uncaught TypeError: “)”.find is not a function for save tab selection on page refresh
[英]“Uncaught TypeError” on page refresh OR new page only…?
当我导航到 HTML/EJS 页面时,以下代码大纲完美运行,它成功地填充了一些标签(以“group_”为前缀)并将图像传递给文档:
外部.js:
addEventListener("load", seeds);
function seeds() {
//...stuff here to define variables and run a loop to populate the tags
//**ADD THE PHOTO...
_item = document.createElement("img");
_item.setAttribute("id", "seed_" + _str);
_item.setAttribute("src", "/galleries/pix/" + _cat + "/" + _str);
_item.setAttribute("alt", "picture of " + _str);
_item.setAttribute("max-width", '100%');
document.getElementById("group_" + _tally).appendChild(_item); //Uncaught TypeError (appendChild) here...ONLY on page 'refresh' or load page in a new tab...works fine the 'first' page load only...
//**
//...more stuff that does not run after the "Uncaught TypeError" on 'reloads'
}
我的问题是,如果我“刷新”页面,或者导航以在新选项卡中再次加载页面...我收到“未捕获的类型错误:无法读取 null 的属性 'appendChild'”错误,并且脚本失败观点。 另一个奇怪的事情是图像是按原样创建的,但是脚本的其余部分停止了功能。
似乎“加载”的事件侦听器第一次运行良好,但是在随后每次尝试加载页面时都会引发错误。 后续页面加载是否可能需要其他一些事件侦听器? 我不认为应该是这样。
非常感谢任何有关问题可能是什么的建议。 我提前谢谢你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.