简体   繁体   English

如何将外部驱动器,外部js文件链接到允许javascript的wordpress插件中?

[英]how do I link an external drive, external js file into a wordpress plugin that allows javascript?

Here is the scenario. 这是场景。 I am running wordpress with the visual composer plugin that allows me to use "RAW js" and I wanted to attach my javascript from my computer to the site. 我正在使用Visual Composer插件运行wordpress,该插件可让我使用“ RAW js”,并且希望将我的JavaScript从计算机附加到站点。 Problem is I am running into is, how do I type the path right if it has a directory? 我遇到的问题是,如果有目录,如何正确键入路径?

I tried to use w3schools "try it yourself" to simulate how to attach it, but it fails to pick it up. 我尝试使用w3schools“自己尝试”来模拟如何附加它,但它没有成功。

Here is what I typed: 这是我输入的内容:

<script type="text/javascript" src="../jquery-v.1.12.4.js"></script>
<script type="text/javascript" src="file:///C:/Site/jquery/jquery-v.1.12.4.js"></script>
<script type="text/javascript" src="jquery-v1.12.4.js"></script>

Obviously i can somply use google apis to pull the version. 显然,我可以立即使用Google API来拉版本。 But this is an example of attaching an external file into a web site coding area. 但这是将外部文件附加到网站编码区域的示例。 And this is a question specifically for the feature of the Visual Composer plugin for wordpress. 这是专门针对Wordpress的Visual Composer插件的功能的问题。 Also, if i have to type it into wordpress manually by 'wp_register_script' . 另外,如果我必须通过'wp_register_script'手动将其键入wordpress中。 How do i write it to pull an external file? 如何编写它以提取外部文件? The "C:" is replaced with a directory outside of it. “ C:”替换为它外部的目录。

I don't think that you can reference a local file like that (file:///) if your index.html is not open from local disk. 如果您未从本地磁盘打开index.html,我认为您不能引用这样的本地文件(file:///)。 Most browsers will simply not allow this operation (at all, or without special exceptions). 大多数浏览器将根本不允许该操作(完全或没有特殊例外)。 Most probably you will see a corresponding error message on the console. 您很可能会在控制台上看到相应的错误消息。

What you may try (at least I did it in some other system) is to insert javascript directly into the field that accepts raw html inside the script tag. 您可以尝试执行的操作(至少我在其他系统中做到了)是直接将javascript插入接受script标记内的原始html的字段中。 meaning, that you copy/paste the script content from your file to there. 意思是,您将脚本内容从文件复制/粘贴到那里。

<script>
   console.log("Hello world!")
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM