簡體   English   中英

外部 js 文件在移動瀏覽器中不起作用

[英]External js file not working in mobile browser

大家下午好/晚上好

為什么在移動瀏覽器(Chrome Mobile、Kiwi)中,外部js文件在 html 文件中不可見?

腳本.js:

alert('hello from script');

接下來我嘗試將此文件包含在 html 代碼中

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

(兩個文件都在同一個文件夾中)

此代碼僅適用於桌面,但不適用於移動瀏覽器我試圖確定完整路徑:

output.innerText = location.href;

然后將其復制到src屬性:

<p id="output">
</p>  
<script src="content://com.estrongs.files/storage/emulated/0/my_files/other/js/test%20script%20src/script.js">
 //output.innerText = location.href;
</script>

仍然不起作用:我嘗試了各種方法: './sript.js'type="text/javascript"也沒有幫助

還能做什么?

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

<p id="output"></p>  
<script>
alert('hello from script');
</script>

工作正常...: https://jsfiddle.net/vm4y0h5L/

“腳本”包含就像添加“src 行”一樣簡單。 ( https://www.w3schools.com/tags/att_script_src.asp )

有關警報的更多信息,請參閱: https://www.w3schools.com/jsref/met_win_alert.asp

PS:仔細檢查你的拼寫......

是“劇本”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM