[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

Beginner HTML / CSS Question. HTA - Only show content if something = true?

Experts,

I've been playing with a locally developed HTA.  The coding isn't clean, as I'm only in it currently to learn the process...  But, I'm trying to accomplish the following, and can't find any information catered to somebody at my "level":

In the HTA *posted below, we're going to be implementing it as a logon banner.  It's looking great, but in this processes, if it the script fails to map drives, etc - I'd like to display that to the end-user as a warning.

I've got the warning area all worked out (at least in function) - but I'm not seeing how I could make it so that it doesn't show at all, unless a condition is met.  (ie. I'd like the warning to show up if there's a global variable set for the error, and not show up if there aren't any errors.)



Sorry if the question is confusing - I'm new to HTML / CSS and don't know much about it .



<html>
<head>
    <title>***</title>

<hta:application
    applicationname="BannerMOTD"
    version="1.0"
    border="thin"
    borderstyle="raised"
    caption="yes"
    contextmenu="yes"
    innerborder="no"
    maximizebutton="no"
    minimizebutton="no"
    selection="yes"
    scroll="yes"
    scrollflat="yes"
    showintaskbar="no"
    SysMenu="no"
    SINGLEINSTANCE="yes"
    ID="CommandLineParams"
>

<style type="text/css">
    textarea
        {
        padding:2px;
        font-family:helvetica, sans-serif;
        font-size:10px;
        inset #ccc;
        overflow:auto;
        border:none;
        outline:none;
        resize:none;
        }
    .preloadedImages
        {
        width:0px;
        height:0px;
        display:inline;
        background:url("\\***\Images\***.gif");
        background:url("\\***\Images\***.gif");
        background:url("\\***\Images\Warning.gif");
        }
    .warning
        {
        padding:2px;
        inset #ccc;
        color:#4F8A10;
        background-color:#FEEFB3;
        }
    div.background
        {
        width:500px;
        height:600px;
        color:yellow;
        background:url("\\***\Images\***.gif") no-repeat center fixed;
        border:2px solid black;
        }
    div.transbox
        {
        width:490px;
        height:590px;
        margin:10px 10px;
        background-color:#ffffff;
        border:1px solid black;
        opacity:0.1;
        filter:alpha(opacity=97);
        }
    div.transbox p
        {
        margin:30px 40px;
        font-weight:bold;
        color:#000000;
        filter:alpha(opacity=100);
        }
</style>
</head>

<SCRIPT LANGUAGE="VBScript">
    Dim strCommandLine,strParams,strParam,arrParams,Output

    Sub Window_Onload
        BannerWidth = "560"
        BannerHeight = "760"

        strComputer = "."
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
        For Each objItem in colItems
            intHorizontal = objItem.ScreenWidth
            intVertical = objItem.ScreenHeight
        Next
        intLeft = (intHorizontal - BannerWidth) / 2
        intTop = (intVertical - BannerHeight) / 2

        window.moveTo intLeft, intTop
        window.resizeTo BannerWidth,BannerHeight

        strCommandLine=CommandLineParams.commandline
        strParams=Right(strCommandLine,Len(strCommandLine)-InStr(2,strCommandLine,"""",0))
            arrLines = Split(strParams, "<BR>")
            strParams=Replace(Replace(Replace(strParams, "<BR>", vbCrLf), chr(34), ""), chr(39), "")

            arrScope = Array("Global", "Error")
            For Each Scope in arrScope
                ScopedOutput = ""
                Output = ""
                If InStr(1, strParams, "<~<" & Scope & ">~>") Then
                    PosSection = InStr(1, strParams, "<~<" & Scope & ">~>", vbTextCompare)
                    If PosSection > 0 Then
                        PosEndSection = InStr(PosSection +1 , strParams, "<~<")
                        If PosEndSection = 0 Then
                            PosEndSection = Len(strParams) + 1
                        End If

                        If Scope <> "" Then
                            ScopedOutput = Replace(Mid(strParams, PosSection, PosEndSection - PosSection), "<~<" & Scope & ">~>", "")
                        End If
                    End If
                End If

                arrOutput=Split(ScopedOutput," ")

                For Each strOutput In arrOutput
                    strOutput = Replace(strOutput, "<SP>", " ")
                    If strOutput <> "" Then
                        Output = Output & strOutput & " "
                    End If
                Next

                Select Case Scope
                    Case "Global"
                        OutputGlobal.Value = Output
                    Case "Error"
                        OutputError.Value = Output
                End Select
            Next

        posBtn
        document.body.onresize = GetRef("posBtn")

        Set WshShell = Nothing
        Set oFSO = Nothing
        Set objFile = Nothing
      End Sub

    Sub posBtn
        Dim btn, bod, leftLoc
        Set btn=document.getelementbyid("runbutton")
        Set bod=document.getelementbyid("Main")
        leftLoc = (bod.offsetWidth/2) - (btn.offsetWidth/2)
        btn.style.position="absolute"
        btn.style.posLeft = leftLoc
      End Sub

    Sub ExitProgram
        window.close()
      End Sub
</SCRIPT>

<body id="Main">
<div class="background">
<div class="transbox">
<center><b><p><img src="\***\Images\***.gif" height="75" width="75" align="left" hspace="10"><br>***<br></p></b></center>
<br>
<center>
<textarea name="OutputGlobal" ID="OutputGlobal" style="font-family:inherit" rows="32" cols="100" readonly="true"></textarea>
<div class="warning"><img src="\\***\Images\Warning.gif" align="left" hspace="5" vspace="5"><textarea name="OutputError" ID="OutputError" style="font-family:Arial" style="background-color:transparent" style="color:#FF0000" rows="6" cols="100" readonly="true"></textarea></div>
</center>
</div>
</div>
<br>
<b><input id=runbutton type="button" value="Acknowledge" style="background-color:gray" onClick="ExitProgram"></b>
<br>
</body>
</html>

Open in new window

0
usslindstrom
Asked:
usslindstrom
1 Solution
 
nap0leonCommented:
In your HTML section, add an If-Then around the 'warning area.

I'm not sure if this is the right way to check for the error condition you are looking for, so it may need to be modified...

<% If Scope = "Error" Then %>
<div class="warning"><img src="\\***\Images\Warning.gif" align="left" hspace="5" vspace="5"><textarea name="OutputError" ID="OutputError" style="font-family:Arial" style="background-color:transparent" style="color:#FF0000" rows="6" cols="100" readonly="true"></textarea></div>
<% End If %>

Open in new window

0
 
usslindstromAuthor Commented:
Thank you very much for the assistance.

I actually ended up going the way of VB, and having the div control hidden, but then having VB change that value within CSS to "block" if the conditions were met.

Much appreciated on the help!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now