简体   繁体   中英

External js file not working in mobile browser

Good afternoon/evening everyone

Why in mobile browsers (Chrome Mobile, Kiwi) the external js file is not visible in the html file?

script.js:

alert('hello from script');

Next I try to include this file in html code with

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

(both files are in the same folder)

This code only works on desktop, but doesn't work on mobile browser I tried to determine the full path with:

output.innerText = location.href;

And then copied it to the src attribute:

<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>

Still doesn't work: I've tried all kinds of ways: './sript.js' and type="text/javascript" also doesn't help

What else can be done?

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

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

Works fine...: https://jsfiddle.net/vm4y0h5L/

The "script" inclusion is just as simple as adding a "src line". ( https://www.w3schools.com/tags/att_script_src.asp )

For more info on alerts, see: https://www.w3schools.com/jsref/met_win_alert.asp

PS: Triple check your spelling...

It's "script".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM