Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BAT/HTA hybrid - How do I escape percent signs in the HTML section?

Tags:

batch-file

hta

I am working on a Batch/HTA hybrid file and want to add some background music to the application. When I try to add a url (containing a percent sign) to a<bgsound> tag, it doesnt play anything. I got it working in another application where the url didn't have any percent signs.

<!-- :: Batch section
@echo off
setlocal EnableDelayedExpansion
start "" mshta.exe "%~f0"
exit /b
-->


<html>
<head>
    <HTA:APPLICATION SCROLL="no" SYSMENU="yes" >
    <title>ACNH - Time Travel Date Selection</title>
    <script language="JavaScript">
    window.resizeTo(1280, 720);
    </script>
</head>
<body>

    <div class="wrapper">
        <h1>Testing audio...</h1>
    </div>
    <bgsound src="https://vgmsite.com/soundtracks/animal-crossing-new-horizons-2020-switch-gamerip/pdjxvsymlc/3-02%20Get%20Ready%20for%20Your%20Flight%21.mp3">

</body>
</html>

I tried adding double percent signs to make batch ignore it but it made no difference. I'm not sure how to escape these characters in the html section

like image 951
bocodes Avatar asked Dec 14 '25 06:12

bocodes


2 Answers

As stated in OJBakker's answer:

The bgsound tag is an Internet Explorer only tag, so this will not work in other browsers.

one inconsistent workaround was to use this instead:

<embed src="https://vgmsite.com/soundtracks/animal-crossing-new-horizons-2020-switch-gamerip/pdjxvsymlc/3-02%20Get%20Ready%20for%20Your%20Flight!.mp3" autostart="true" loop="false" width="0" height="0">

The final solution was found by LesFerch:

Please note that your HTA is missing any doctype or document mode declaration. Therefore, it's running in IE 5 mode. To put that in perspective, IE 5 was released in 1999. Please see "Further background information on HTA document modes" in this answer. In general, you're best bet is to run in IE 11 mode, but there are situations where running in an older mode may be desirable. – LesFerch

basically I was defaulting to IE-5. Adding this changes it to IE-11

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" http-equiv="X-UA-Compatible" content="IE=11">
<hta:application id=oHTA>
</head>

I now had access to the <audio> tag and used that as a solution

<audio autoplay>
<source src="https://vgmsite.com/soundtracks/animal-crossing-new-horizons-2020-switch-gamerip/pdjxvsymlc/3-02%20Get%20Ready%20for%20Your%20Flight!.mp3" type="audio/mpeg">
</audio>
like image 186
bocodes Avatar answered Dec 16 '25 23:12

bocodes


The bgsound tag is an Internet Explorer only tag, so this will not work in other browsers.

like image 23
OJBakker Avatar answered Dec 16 '25 23:12

OJBakker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!