3 examples of 'insertbefore js' in JavaScript

Every line of 'insertbefore js' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
48export function insertBeforeFirstScript (el: ASTNode, parent: ASTNode): void {
49 el.namespaceURI = parent.namespaceURI;
50 el.parentNode = parent;
51
52 const firstScriptIndex = parent.childNodes.findIndex(node => node.tagName === 'script');
53 const elIndex = firstScriptIndex !== -1 ? firstScriptIndex : parent.childNodes.length;
54
55 parent.childNodes.splice(elIndex, 0, el);
56}
47function insertScript() {
48 window.urlfix_groupID = document.URL.replace(/^.+id=/,'').replace('#', '');
49 window.urlfix_groupSite = window.urlfix_grouplist[window.urlfix_groupID];
50 window.urlfix_openSuggBox = function(){var suggboxurl = "http://mufix.herokuapp.com/form?group=" + urlfix_groupID; if(urlfix_groupSite !== "undefined") suggboxurl += "&update=yes"; window.open(suggboxurl, '', 'scrollbars=no,resizable=yes, width=700,height=200,status=no,location=no,toolbar=no');};
51 var urlfix_site = document.createElement('tr');
52 urlfix_site.innerHTML = '<td><u>Site</u><a href="#"> (Suggest an update)</a></td><td><a target="_blank" href="' + urlfix_groupSite + '"><u>' + urlfix_groupSite + '</u></a></td>';
53 var urlfix_irc_par = document.getElementById("fixed_irc_url").parentNode;
54 urlfix_irc_par.parentNode.insertBefore(urlfix_site, urlfix_irc_par.nextSibling);
55}
25function insertScript(inline, data) {
26 var script = document.createElement('script');
27 script.setAttribute('id', '__lg_script');
28 if(inline)
29 script.appendChild(document.createTextNode(data));
30 else
31 script.setAttribute('src', data);
32
33 // FF: there is another variables in the scope named parent, this causes a very hard to catch bug
34 var _parent = document.head || document.body || document.documentElement;
35 var firstChild = (_parent.childNodes &amp;&amp; (_parent.childNodes.length &gt; 0)) ? _parent.childNodes[0] : null;
36 if(firstChild)
37 _parent.insertBefore(script, firstChild);
38 else
39 _parent.appendChild(script);
40}

Related snippets