Solved

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

Posted on 2012-03-11
2
326 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
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)

705 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