admin管理员组

文章数量:1289346

I am trying to load an external library to the admin section of my website. On the front end it is pretty easy to load.

<head>
 <script src="externalLibrary"></script>
 <script src="externalLibrary"></script>
 <script src="externalLibrary"></script>
 <script src="externalLibrary"></script>
 <script src="externalLibrary"></script>
 <script src="externalLibrary"></script>
</head>

On the back-end we don't have access to the head section so the library links have to be loaded from an external file.

function myCustomScript($hook) {
 
    wp_enqueue_script( 'admin-js', plugins_url( 'admin-columns/js/admin.js' , dirname(__FILE__) ) );
}
add_action('admin_enqueue_scripts', 'myCustomScript');

The external file loads perfectly, I just need help making the urls available in the external file.

This is what I have tried in the js file

var sc = document.createElement("script");
sc.setAttribute("src", ".js");
sc.setAttribute("type", "text/javascript");
document.head.appendChild(sc);
document.getElementsByTagName("head")[0].appendChild(sc);

本文标签: javascriptHow do I load urls from an external js file to my admin head