我有2个html页面。第一个是main.html
这是我的主页。在第二个,我创建了一个textarea
它自己的css
样式和javascript
函数。我想把这个textarea包含进去main.html
。我独立创建它,因为它的造型和JS代码已经太大了,我不想在main.html
中造成阻塞。正确合并2个html页面的css和javascript代码
main.html text.html
<html> <style>
<head> //CSS codes
<style> </style>
//some css in there
//want to add text.html's css codes in there
</style> <div>
</head> <textarea>
<body> </textarea>
<div>some content in here</div> </div>
<div>some content in here</div>
<div>some content in here</div> <script>
//JS codes
</script>
<script>
//some javascript goes there
//want to add text.html's js codes there
</script>
</body>
</html>
我知道我可以使用PHP的包括内部main.html
像<?php include 'text.html'; ?>
功能或者我可以使用。但是对于这两种解决方案,<style>
和<script>
标签都出现在main.html
的中间,这是一个丑陋且不需要的场景。这正是我在这里的主要问题。我想将text.html
的CSS代码放入main.html
的<style>
标记以及text.html
的js代码中,输入main.html
的<script>
标记。有没有什么可以做到这一点的魔术?
请不要在你的问题中使用咒骂。 –