在html中嵌入javascript文件 [英] Embed javascript file in html

查看:121
本文介绍了在html中嵌入javascript文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用html设计一个设计师。我在画布上绘制小部件然后在保存按钮单击画布下载为用户PC上的html页面。但问题是我使用的小部件需要链接两个JavaScript文件。即我必须将这两个JavaScript文件粘贴到下载的html页面的目录中。否则它不起作用。
那么有没有办法将这些文件嵌入我保存的文件中。我不希望用户将粘贴.js文件与html文件一起复制。

I am designing a designer in html. I am drawing widgets on canvas and then on save button click canvas is downloaded as html page on user PC. But problem is that widgets that i am using need two JavaScript files to be linked. i.e. I have to paste those two JavaScript file in the directory of downloaded html page. Otherwise it didn't work. So is there a way to embed these files in my saved file. I don't want user to copy paste .js files along with html file.

推荐答案

您可以复制并粘贴这些JavaScript文件'脚本块中的内容并删除它们的引用。例如,更改:

You can copy and paste these JavaScript files' content in a script block and remove their references. For example, change:

<script src="external.js"></script>

to:

<script>
  // copy and paste the content of external.js here
</script>

对所有JavaScript依赖项执行此操作。

Do this to all the JavaScript dependencies.

这篇关于在html中嵌入javascript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆