Solved

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

Posted on 2012-03-11
2
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
nap0leon earned 500 total points
ID: 37709688
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
ID: 37718473
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Navigation Menu Does Not Show on iPad 4 30
Link not working 6 41
HTML auto refresh to another site 4 28
Link Anchor Not working 9 46
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

735 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