How do I make the text in my .hta (.Html application) not selectable?

I have several span elements in an .HTA script and I would like to prevent the user from selecting any text. My script looks like:
<html>
<head>
<HTA:APPLICATION
     ID="objScreen" 
     APPLICATIONNAME="Screen" 
     BORDER="none" 
     BORDERSTYLE="normal" 
     CAPTION="no" 
     ICON="" 
     MAXIMIZEBUTTON="no" 
     MINIMIZEBUTTON="no" 
     SHOWINTASKBAR="yes" 
     SINGLEINSTANCE="yes" 
     SYSMENU="no" 
     SCROLL="no" 
     VERSION="1.0" 
     CONTEXTMENU="no" 
     WINDOWSTATE="maximize"
     INNERBORDER="no"/> 




</head>



<SPAN
   STYLE="
      top: 203;
      left: 572;
      width: 42px;
      height: 43px; 
      position: absolute;
      z-index: 1;
      background-image: url('Busy.gif');
      visibility: show;">
</SPAN>
<SPAN
   STYLE="
      top: 263;
      left: 572;
      width: 42px;
      height: 43px; 
      position: absolute;
      z-index: 1;
      background-image: url('Busy.gif');
      visibility: show;">
</SPAN>
<SPAN
   STYLE="
      top: 323;
      left: 572;
      width: 42px;
      height: 43px; 
      position: absolute;
      z-index: 1;
      background-image: url('Busy.gif');
      visibility: show;">
</SPAN>
<SPAN
   STYLE="
      top: 383;
      left: 572;
      width: 20px;
      height: 20px; 
      position: absolute;
      z-index: 1;
      background-image: url('Busy.gif');
      visibility: show;">
</SPAN>
<SPAN
   STYLE="
      top: 443;
      left: 572;
      width: 42px;
      height: 43px; 
      position: absolute;
      z-index: 1;
      background-image: url('Busy.gif');
      visibility: show;">
</SPAN>
<SPAN
   STYLE="
      top: 503;
      left: 572;
      width: 42px;
      height: 43px; 
      position: absolute;
      z-index: 1;
      background-image: url('Busy.gif');
      visibility: show;">
</SPAN>
<SPAN
   STYLE="
      top: 563;
      left: 572;
      width: 42px;
      height: 43px; 
      position: absolute;
      z-index: 1;
      background-image: url('Busy.gif');
      visibility: show;">
</SPAN>





<Script Language="VBScript"> 

   Sub Window_OnLoad 
      ' Size and position main window
      window.resizeTo 1366,768 
      window.moveTo 0,0

      ' Display current time
      myClock.innerText = Now()

      ' Set up a timer event so we can update the screen periodically
      iTimerID = window.setInterval("myVBSClock", 1000) 
   End Sub    

   Sub myVBSClock 
      ' Update current time
      myClock.innerText = Now()

      ' Refresh colors from status file
      CheckStatusFile
   End Sub 

   Function ComputerName()
      ' Get computername
      Set wshShell = CreateObject("WScript.Shell")
      ComputerName = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
      Set wshShell = Nothing
   End Function

   Sub CheckStatusFile
      ' Constants for file I/O
      Const ForReading = 1
      Const ForWriting = 2
      Const TriStateUseDefault = -2

      ' Name of status file
      strStatusFile = "Status.txt"

      ' Create file system object
      Set objFSO = CreateObject("Scripting.FileSystemObject")

      ' Make sure status file exists
      If objFSO.FileExists(strStatusFile) Then
         ' Open it for reading
         Set objStatusFile = objFSO.OpenTextFile(strStatusFile, ForReading, False, TriStateUseDefault)
         ' Read status file, slit lines into array elements
         arrStatus = Split(objStatusFile.ReadAll, vbCrLf)
         ' Close file, release objects
         objStatusFile.Close
         Set objStatusFile = Nothing
         Set objFSO = Nothing

         ' Process each line of the status file (skip blank lines)
         For Each strStatus in arrStatus
            If strStatus <> "" Then
               ' Split status line into array at comma
               arrField = Split(strStatus, ",")
               ' Process lines based on first field on line (item name to update), and set item color to status file value
               Select Case arrField(0)
                  Case "Security-Environment"
                     SecurityEnvironment.style.background = arrField(1)
                  Case "Help-Menu"
                     HelpMenu.style.background = arrField(1)
                  Case "Biometric-License"
                     BiometricLicense.style.background = arrField(1)
                  Case "Card-Printer"
                     CardPrinter.style.background = arrField(1)
                  Case "GPS-Device"
                     GPSDevice.style.background = arrField(1)
                  Case "Battery-Controller"
                     BatteryController.style.background = arrField(1)
                  Case "Biometric-Application"
                     BiometricApplication.style.background = arrField(1)
               End Select
            End If
         Next 
      End If
   End Sub

</SCRIPT> 


<BODY
     BACKGROUND="bgimageV3.jpg"
     TOPMARGIN="10"
     RIGHTMARGIN="10"
     LEFTMARGIN="10"
     BGCOLOR="#7e7e7e"> 



<SPAN
   id="SecurityEnvironment"
   style="
      top: 200;
      left: 47;
      width: 570px;
      height: 40px; 
      position: absolute;
      z-index: 1;
      background: grey;
      border-color: #000000;
      border-style: solid;
      border-top-width: 1px;
      border-bottom-width: 1px;
      border-left-width: 1px;
      border-right-width: 1px;
      text-align: left;
      color: white;
      font-family: Arial;
      font-size : 40;
      visibility: show;">
SECURITY ENVIRONMENT
</SPAN>

<SPAN
   id="HelpMenu"
   style="
      top: 260;
      left: 47;
      width: 570px;
      height: 40px; 
      position: absolute;
      z-index: 1;
      background: grey;
      border-color: #000000;
      border-style: solid;
      border-top-width: 1px;
      border-bottom-width: 1px;
      border-left-width: 1px;
      border-right-width: 1px;
      text-align: left;
      color: white;
      font-family: Arial;
      font-size : 40;
      visibility: show;">
HELP MENU
</SPAN>

<SPAN
   id="BiometricLicense"
   style="
      top: 320;
      left: 47;
      width: 570px;
      height: 40px; 
      position: absolute;
      z-index: 1;
      background: grey;
      border-color: #000000;
      border-style: solid;
      border-top-width: 1px;
      border-bottom-width: 1px;
      border-left-width: 1px;
      border-right-width: 1px;
      text-align: left;
      color: white;
      font-family: Arial;
      font-size : 40;
      visibility: show;">
BIOMETRIC LICENSE
</SPAN>

<SPAN
   id="CardPrinter"
   style="
      top: 380;
      left: 47;
      width: 570px;
      height: 40px; 
      position: absolute;
      z-index: 1;
      background: grey;
      border-color: #000000;
      border-style: solid;
      border-top-width: 1px;
      border-bottom-width: 1px;
      border-left-width: 1px;
      border-right-width: 1px;
      text-align: left;
      color: white;
      font-family: Arial;
      font-size : 40;
      visibility: show;">
CARD PRINTER
</SPAN>

<SPAN
   id="GpsDevice"
   style="
      top: 440;
      left: 47;
      width: 570px;
      height: 40px; 
      position: absolute;
      z-index: 1;
      background: grey;
      border-color: #000000;
      border-style: solid;
      border-top-width: 1px;
      border-bottom-width: 1px;
      border-left-width: 1px;
      border-right-width: 1px;
      text-align: left;
      color: white;
      font-family: Arial;
      font-size : 40;
      visibility: show;">
GPS DEVICE
</SPAN>

<SPAN
   id="BatteryController"
   style="
      top: 500;
      left: 47;
      width: 570px;
      height: 40px; 
      position: absolute;
      z-index: 1;
      background: grey;
      border-color: #000000;
      border-style: solid;
      border-top-width: 1px;
      border-bottom-width: 1px;
      border-left-width: 1px;
      border-right-width: 1px;
      text-align: left;
      color: white;
      font-family: Arial;
      font-size : 40;
      visibility: show;">
BATTERY CONTROLLER
</SPAN>

<SPAN
   id="BiometricApplication"
   style="
      top: 560;
      left: 47;
      width: 570px;
      height: 40px; 
      position: absolute;
      z-index: 1;
      background: grey;
      border-color: #000000;
      border-style: solid;
      border-top-width: 1px;
      border-bottom-width: 1px;
      border-left-width: 1px;
      border-right-width: 1px;
      text-align: left;
      color: white;
      font-family: Arial;
      font-size : 40;
      visibility: show;">
BIOMETRIC APPLICATION"
</SPAN>

<SPAN
   style="
      top: 650;
      left: 50;
      width: 570px;
      height: 40px; 
      position: absolute;
      z-index: 1;
      text-align: left;
      color: fa8b0f;
      font-family: Arial;
      font-size : 60;
      visibility: show;">
<script type="text/javascript"> document.write(computername());</script>
</SPAN>

<SPAN
   style="
      top: 670;
      left: 515;
      width: 570px;
      height: 40px;
      position: absolute;
      z-index: 1;
      text-align: left;
      color: white;
      font-family: Arial;
      font-face : Arial;
      font-size : 25;
      font-weight: bold;
      visibility: show;">
<font color="white"><PRE ID=myClock></font>
</SPAN>






</BODY> 
</HTML>

Open in new window

Rebel_no_1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rebel_no_1Author Commented:
I have found this code but cannot get it to work.
.noselect {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

<p>
  Selectable text.
</p>
<p class="noselect">
  Unselectable text.
</p>

Open in new window

Rebel_no_1Author Commented:
Here is another piece of code which seems to be able to do this. I just don't know how to make it part of my script to test?

<!-- Paste this code into an external JavaScript file named: disableSelect.js  -->

/* This script and many more are available free online at
The JavaScript Source :: http://www.javascriptsource.com
Created by: James Nisbet (morBandit) :: http://www.bandit.co.nz/ */

window.onload = function() {
  document.onselectstart = function() {return false;} // ie
  document.onmousedown = function() {return false;} // mozilla
}


/* You can attach the events to any element. In the following example
I'll disable selecting text in an element with the id 'content'. */

window.onload = function() {
  var element = document.getElementById('content');
  element.onselectstart = function () { return false; } // ie
  element.onmousedown = function () { return false; } // mozilla
}



<!-- Paste this code into the HEAD section of your HTML document.
     You may need to change the path of the file.  -->

<script type="text/javascript" src="disableSelect.js"></script>

Open in new window

RobSampsonCommented:
Hi, you can combine your last snippet with your first one and it works.

Under your existing </SCRIPT> tag, add this
<script language="javascript">
/* This script and many more are available free online at
The JavaScript Source :: http://www.javascriptsource.com
Created by: James Nisbet (morBandit) :: http://www.bandit.co.nz/ */
window.onload = function() {
  document.onselectstart = function() {return false;} // ie
  document.onmousedown = function() {return false;} // mozilla
}
</script>

Open in new window


That should do it.

Regards,

Rob.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Rebel_no_1Author Commented:
This is a handy trick to stop people from selecting text. I had to place it within it's own script tags for some reason but I'm sure this is due to a possible problem elsewhere in my code. I will clean things up later and as I gain new knowledge. Thank you Rob!
RobSampsonCommented:
No problem. You already have <script> tags for your vbscript code, so you need a new set for javascript code.  The entire snippet that I posted has its own tags for that reason.

Happy learning!
Rebel_no_1Author Commented:
I see what you mean. I'm still learning but I'll get there eventually! Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.