我有以下工作示例應用程序,它在終端窗口中顯示鍵入文本:第 1 步 - 沒有問題的工作示例(一個文件夾中有 3 個文件:index.php,style.css和typed-custom.js)我有以下內容style.css: .terminal-window { text-align: left; width: 620px; height: 650px; border-radius: 10px; margin: auto; position: relative;}.terminal-window section.terminal { color: white; font-family: Menlo, Monaco, "Consolas", "Courier New", "Courier"; font-size: 11pt; background: black; padding: 10px; box-sizing: border-box; position: absolute; width: 100%; top: 30px; bottom: 0; overflow: auto;}.term-home{color: #0095ff;}我有以下內容typed-custom.js$(function() { var data = [ { action: 'type', strings: ["typing-1:"], output: '<span class="green"><small> This is first typing</small></span> ', postDelay: 1000, }, { action: 'type', strings: ["typing-2:"], output: '<span class="green"><small>This is second typing</small></span> ', postDelay: 1000 }, ]; runScripts(data, 0);});function runScripts(data, pos) { var prompt = $('.prompt'), script = data[pos]; if(script.clear === true) { $('.history').html(''); } switch(script.action) { case 'type': // cleanup for next execution prompt.removeData(); $('.typed-cursor').text(''); prompt.typed({ strings: script.strings, typeSpeed: 10, callback: function() { var history = $('.history').html(); history = history ? [history] : []; history.push('<span class="term-home">root:~$</span> ' + prompt.text()); if(script.output) { history.push(script.output); prompt.html(''); $('.history').html(history.join('<br>')); }
1 回答

楊魅力
TA貢獻1811條經驗 獲得超6個贊
如果 load.php 打算插入到 index.php 中,那么它不應該有自己的 html、head 和 body 標簽。它應該只是將要注入主頁的 HTML 片段。在另一個 HTML 文檔中加載一個全新的獨立 HTML 文檔(由 html/head/body 標記表示)沒有任何意義。
另外...您只是在 index.php 完成加載后立即將“load.php”添加到頁面。相反,您可以通過 PHP 的命令包含它include
- 這樣它就可以與 index.php 同時發送到瀏覽器,而無需單獨獲取。這樣會更有效率并且更不容易出錯。
并且 load.php 不需要添加 jQuery 的另一個副本,因此您可以刪除它 - 它可能會導致沖突或意外行為。瀏覽器將這兩個文件視為單個頁面的一部分,因此它只需要一個 jQuery 副本。
- 1 回答
- 0 關注
- 150 瀏覽
添加回答
舉報
0/150
提交
取消