我有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>
標記。有沒有什麼可以做到這一點的魔術?
請不要在你的問題中使用咒罵。 –