Solved

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

Posted on 2012-03-11
2
302 Views
Last Modified: 2012-06-22
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
Comment
Question by:usslindstrom
2 Comments
 
LVL 18

Accepted Solution

by:
nap0leon earned 500 total points
Comment Utility
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
 
LVL 5

Author Closing Comment

by:usslindstrom
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now