use a part of html tag src from script in a Hta (html application)

186 Views Asked by At

enter image description here I use css in my hta with ie=10.

Note: It should be noted that I am using this code as an HTA program, not on a web page

<script language = "vbscript" type = "text/vbscript">
         Const CNS="Provider=SQLOLEDB;Initial Catalog=PhoneBook;Data Source=SERVER\SGMSQLSERVER2019;User ID=sa;Password=md13@48;"
         Const FinalPic="file:///d:/Webprojectk"
            
            public connect
            Set connect = CreateObject("ADODB.Connection")
             connect.ConnectionString = CNS
            connect.Open
         
      </script> 

Now I want to use this static address for various tags such as CSS addresses and JavaScript files, etc. in the head abd body part of the page.

           <link rel="stylesheet" href= FinalPic  + "/css/bootstrap.min.css">
            
       <script src= FinalPic  + "/java/jquery.min.js"></script>
       
       <script LANGUAGE="VBScript" src= FinalPic  + "/vb/ed.vbs"></script>
       
          <img src=   FinalPic  + "/picture/ramadan.gif" style="width:10%">


Of course, I tried to do this, but apparently there is a problem and I can't use this variable in the HTML code. Please help me.

I put my complete and simple my code here. please look at here again:

<!DOCTYPE html>
<head>
<HTA:APPLICATION>
 </head>
        <meta http-equiv="x-ua-compatible" content="ie=10"/>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        
        <!-----I put css  js vbs pictures and other files in different folders------->
        
        <link  href= path  + "/css/bootstrap.min.css" rel="stylesheet">
        <script src= path  + "/java/jquery.min.js"></script>
        <script LANGUAGE="VBScript" src= path  + "/vb/ed.vbs"></script>
       

<script language="VBScript">
Sub Window_OnLoad
    msgbox path  
End Sub
</script>

<body>

alert(path)
    <img src=   path  + "/picture/flower.gif" style="width:10%">
     <!--here  define what I want to call onload hta-->
   <script language = "vbscript" type = "text/vbscript">
         Const path="file:///d:/Webproject"
   </script>        
</body>
</html>
1

There are 1 best solutions below

0
LesFerch On

As @Teemu stated, you need to use a <base> element to set the resource path. See example below.

Also, note that IE=10 mode does not support <HTA:APPLICATION>, so you can remove that line. If you need any features provided by that section, you will either need to drop down to IE=9 or split your file into two parts or use the VbsEdit HTM to EXE feature.

Also watch your case. For example Window_OnLoad should be window_onload.

<!DOCTYPE html>
<head>
<meta http-equiv="x-ua-compatible" content="IE=10">
<base href="file:///C:/Resources/">
<link href = "css/bootstrap.min.css" rel="stylesheet">
<script language="JScript" src = "js/jquery.min.js"></script>
<script language="VBScript" src = "vbs/ed.vbs"></script>
</head>
<body>
  <img src = "pic/flower.gif">
</body>
</html>