apply style to InnerHTML

Discussion in 'HTML' started by rob.fahndrich@gmail.com, Aug 1, 2007.

  1. Guest

    <style type="text/css">
    ..bluetext {font-family: Comic Sans MS; font-size: 18pt; color:
    #000066;text-decoration: none;}
    ..redtext {font-family: Comic Sans MS; font-size: 18pt; color:
    #000066;text-decoration: none;}
    </style>

    </head>


    <SCRIPT LANGUAGE="VBScript">


    Sub GetInfoSub
    Set objNet = CreateObject("WScript.NetWork")
    ComputerName.InnerHTML = "<font face=Arial Size=4 color=blue>" &
    objNet.ComputerName & "</font>"
    End Sub


    </SCRIPT>


    this code above "ComputerName.InnerHTML" formats my text as I would
    like it to be. I would like to use something like the following to
    format my text instead:


    ComputerName.InnerHTML = "<p class="redtext">" & objNet.ComputerName
    & "</p>"


    this code will not work and generates errors.
    how can I use the .redtext class for my InnerHTML code???
    , Aug 1, 2007
    #1
    1. Advertising

  2. John Hosking Guest

    wrote:
    > <style type="text/css">
    > .bluetext {font-family: Comic Sans MS; font-size: 18pt; color:
    > #000066;text-decoration: none;}


    Points? Is this a print stylesheet? In color??

    > .redtext {font-family: Comic Sans MS; font-size: 18pt; color:
    > #000066;text-decoration: none;}


    Nothing red about #000066.

    > </style>
    >
    > </head>


    You've lost your <head>. You're also missing the <title>.

    >
    > <SCRIPT LANGUAGE="VBScript">


    I don't see this very often.

    > Sub GetInfoSub
    > Set objNet = CreateObject("WScript.NetWork")
    > ComputerName.InnerHTML = "<font face=Arial Size=4 color=blue>" &
    > objNet.ComputerName & "</font>"
    > End Sub


    See, this shows how weak I am in VBScript; what is ComputerName when you
    first reference it? And how does it get to be part of objNet (or is that
    a different one, part of the NetWork object)?

    > </SCRIPT>
    >
    > this code above "ComputerName.InnerHTML" formats my text as I would
    > like it to be.


    Well, that's a happy surprise.

    > I would like to use something like the following to
    > format my text instead:
    >
    > ComputerName.InnerHTML = "<p class="redtext">" & objNet.ComputerName
    > & "</p>"
    >
    > this code will not work and generates errors.
    > how can I use the .redtext class for my InnerHTML code???


    What errors, then?
    What is the innerHTML supposed to be within? Your first example was
    inline content, now you're adding a <p> element. Where's the URL to the
    rest of the code?
    Have you tried different delimiters:
    ComputerName.InnerHTML = "<p class='redtext'>" & objNet.ComputerName
    & "</p>" ?

    --
    John
    Pondering the value of the UIP: http://blinkynet.net/comp/uip5.html
    John Hosking, Aug 1, 2007
    #2
    1. Advertising

  3. rf Guest

    <> wrote in message
    news:...

    > ComputerName.InnerHTML = "<p class="redtext">" & objNet.ComputerName
    > & "</p>"



    ComputerName.InnerHTML = "<p class='redtext'>" & objNet.ComputerName &
    "</p>"

    --
    Richard.
    rf, Aug 1, 2007
    #3
  4. Guest

    On Aug 1, 12:18 am, "rf" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    > > ComputerName.InnerHTML= "<p class="redtext">" & objNet.ComputerName
    > > & "</p>"

    >
    > ComputerName.InnerHTML= "<p class='redtext'>" & objNet.ComputerName &
    > "</p>"
    >
    > --
    > Richard.


    thank you. it was the ' not the " that worked...

    here is the code that I was working on:

    ---------------------------------------------------------------------

    <html>
    <head>
    <title>HTA Test</title>
    <HTA:APPLICATION
    ID = "oApp"
    APPLICATIONNAME = "TEST"
    BORDER = "normal"
    BORDERSTYLE = "normal"
    CAPTION = "no"
    ICON = "explorer.exe"
    SHOWINTASKBAR = "no"
    SINGLEINSTANCE = "yes"
    SYSMENU = "no"
    WINDOWSTATE = "normal"
    SCROLL = "no"
    SCROLLFLAT = "no"
    VERSION = "1.2"
    INNERBORDER = "yes"
    SELECTION = "no"
    MAXIMIZEBUTTON = "no"
    MINIMIZEBUTTON = "no"
    NAVIGABLE = "no"
    CONTEXTMENU = "no"
    >


    <style type="text/css">
    ..bluetext {font-family: Comic Sans MS; font-size: 10pt; color:
    blue;text-decoration: none;cursor: default;}
    ..redtext {font-family: Comic Sans MS; font-size: 10pt; color: red;text-
    decoration: none;cursor: default;}
    ..whitetext {font-family: Comic Sans MS; font-size: 10pt; color:
    white;text-decoration: none;cursor: hand;}
    </style>


    </head>

    <SCRIPT Language="VBScript">
    Sub Window_Onload


    CitrixPN.style.visibility="hidden"
    VisionAPP.style.visibility="hidden"

    strComputer = "."
    On Error Resume Next
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root
    \cimv2")
    Set colInstalledPrinters = objWMIService.ExecQuery _
    ("Select * from Win32_Printer")
    For Each objPrinter in colInstalledPrinters
    if (objPrinter.Attributes AND 4) = 4 then _
    DataArea.InnerHTML = "<p class='redtext'>" & objPrinter.Name & "</
    p>"
    Next

    Set objNet = CreateObject("WScript.NetWork")
    UserName.InnerHTML = "<p class='redtext'>" & objNet.UserName & "</
    p>"

    Set objNet = CreateObject("WScript.NetWork")
    ComputerName.InnerHTML = "<p class='redtext'>" & objNet.ComputerName
    & "</p>"

    set wsh = WScript.CreateObject ("WScript.Shell")
    Select Case LCase(objNet.UserName)

    Case "test"
    CitrixPN.style.visibility="visible"
    VisionAPP.style.visibility="visible"

    End Select

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root
    \cimv2")

    Set colAdapters = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled =
    True")

    n = 1

    For Each objAdapter in colAdapters
    If Not IsNull(objAdapter.IPAddress) Then
    For i = 0 To UBound(objAdapter.IPAddress)
    IPSpan.InnerHTML = "<p class='redtext'>" & objAdapter.IPAddress(i)
    & "</p>"
    Next
    End If

    n = n + 1

    Next

    End Sub
    </SCRIPT>

    <SCRIPT LANGUAGE="VBScript">
    Sub VisionAPPRDP
    On Error Resume Next
    set wshshell = CreateObject("WScript.Shell")
    wshshell.run """C:\Program Files\visionapp\visionapp Remote Desktop
    \vrd.lnk""", 1, FALSE
    End Sub

    Sub PrattPN
    On Error Resume Next
    set wshshell = CreateObject("WScript.Shell")
    wshshell.run "C:\Progra~1\Citrix\ICACli~1\pn.exe /PN:""PWCS Farm""",
    1, FALSE
    End Sub

    Sub ExitProgram
    window.close()
    End Sub

    </SCRIPT>

    <body topmargin="0" leftmargin="0" rightmargin="0" bgcolor="#C0C0C0">

    <div id="TimeHeader" align="center" style="background-color:blue">
    <table border="0" width="100%" class="blutest" height="10">
    <tr>
    <td align="center" width="100%">
    <script language="javascript">
    function det_time(){
    var d = new Date();
    var dstr = d.toLocaleString();
    document.getElementById('time').innerHTML = dstr;
    }
    </script>
    <div id="time" name="time" style="font-family:comic sans ms;font-
    size:11pt;color:white;font-weight:normal;text-align:CENTER;"><br></
    div>
    <script language="javascript">
    det_time();
    setInterval("det_time()", 1000);
    </script>
    </td>
    </tr>
    </table>
    </div>

    <div id="Header" align="center" style="background-color:yellow">
    <table border="0" width="100%" class="bluetext">
    <tr>
    <td align="right" width="56%">
    Current Default Printer is:
    </td>
    <td align="left" width="44%">
    <span id = "DataArea"></span>
    </td>
    </tr>
    <tr>
    <td align="right" width="56%">
    Current Username is:
    </td>
    <td align="left" width="44%">
    <span id = "UserName"></span>
    </td>
    </tr>
    <tr>
    <td align="right" width="56%">
    Current Computer Name is:
    </td>
    <td align="left" width="44%">
    <span id = "ComputerName"></span>
    </td>
    </tr>
    <tr>
    <td align="right" width="56%">
    Current IP Address is:
    </td>
    <td align="left" width="44%">
    <span id = "IPSpan"></span>
    </td>
    </tr>
    </table>
    </div>

    <div id="TimeFooter" align="center" style="background-color:blue">
    <table border="0" width="100%" class="blutest">
    <tr>
    <td align="center" width="100%" height="10">
    </td>
    </tr>
    </table>
    </div>
    <br>

    <div id="buttons" align="center">
    <button style="background-color:blue" class="whitetext"
    name="CitrixPN" onclick="PrattPN" style="width: 258; height:
    26">Citrix Program Neighborhood</button><p>
    <button style="background-color:blue" class="whitetext"
    name="VisionAPP" onclick="VisionAPPRDP" style="width: 258; height:
    26">VisionAPP RDP</button><p>
    <button style="background-color:blue" class="whitetext"
    name="CloseWindow" onclick="ExitProgram" style="width: 258; height:
    26" >Close</button><p>
    <br>
    </div>

    </body>
    </html>

    <script language="vbscript">
    'Option Explicit
    PositionWindow()
    Sub PositionWindow()
    Dim WindowWidth, WindowHeight, LeftPos, TopPos
    WindowWidth = 375
    WindowHeight = 500
    LeftPos = (screen.availWidth - WindowWidth) / 2
    TopPos = (screen.availHeight - WindowHeight) / 2
    window.resizeTo WindowWidth, WindowHeight
    window.moveTo LeftPos, TopPos
    End Sub
    </script>

    <script type="text/javascript">
    function startProg(myPath)
    {
    var WshShell = new ActiveXObject("wscript.shell");
    WshShell.Run("\""+myPath);
    }
    </script>

    ---------------------------------------------------------------------------------------------------------------------------

    save as an .hta file
    Thanks.
    , Aug 13, 2007
    #4
  5. Guest

    On Aug 1, 12:15 am, John Hosking <>
    wrote:
    > wrote:
    > > <styletype="text/css">
    > > .bluetext {font-family: Comic Sans MS; font-size: 18pt; color:
    > > #000066;text-decoration: none;}

    >
    > Points? Is this a print stylesheet? In color??
    >
    > > .redtext {font-family: Comic Sans MS; font-size: 18pt; color:
    > > #000066;text-decoration: none;}

    >
    > Nothing red about #000066.
    >
    > > </style>

    >
    > > </head>

    >
    > You've lost your <head>. You're also missing the <title>.
    >
    >
    >
    > > <SCRIPT LANGUAGE="VBScript">

    >
    > I don't see this very often.
    >
    > > Sub GetInfoSub
    > > Set objNet = CreateObject("WScript.NetWork")
    > > ComputerName.InnerHTML= "<font face=Arial Size=4 color=blue>" &
    > > objNet.ComputerName & "</font>"
    > > End Sub

    >
    > See, this shows how weak I am in VBScript; what is ComputerName when you
    > first reference it? And how does it get to be part of objNet (or is that
    > a different one, part of the NetWork object)?
    >
    > > </SCRIPT>

    >
    > > this code above "ComputerName.InnerHTML" formats my text as I would
    > > like it to be.

    >
    > Well, that's a happy surprise.
    >
    > > I would like to use something like the following to
    > > format my text instead:

    >
    > > ComputerName.InnerHTML= "<p class="redtext">" & objNet.ComputerName
    > > & "</p>"

    >
    > > this code will not work and generates errors.
    > > how can I use the .redtext class for myInnerHTMLcode???

    >
    > What errors, then?
    > What is theinnerHTMLsupposed to be within? Your first example was
    > inline content, now you're adding a <p> element. Where's the URL to the
    > rest of the code?
    > Have you tried different delimiters:
    > ComputerName.InnerHTML= "<p class='redtext'>" & objNet.ComputerName
    > & "</p>" ?
    >
    > --
    > John
    > Pondering the value of the UIP:http://blinkynet.net/comp/uip5.html


    in fairness that was only a small snippet of the code. I was wanting
    to use a stylesheet to the innerHTML but am not real good with HTML.
    the ' did the trick, not the "
    here is the code that i am currently working on:

    ---------------------------------------------------------------------

    <html>
    <head>
    <title>HTA Test</title>
    <HTA:APPLICATION
    ID = "oApp"
    APPLICATIONNAME = "TEST"
    BORDER = "normal"
    BORDERSTYLE = "normal"
    CAPTION = "no"
    ICON = "explorer.exe"
    SHOWINTASKBAR = "no"
    SINGLEINSTANCE = "yes"
    SYSMENU = "no"
    WINDOWSTATE = "normal"
    SCROLL = "no"
    SCROLLFLAT = "no"
    VERSION = "1.2"
    INNERBORDER = "yes"
    SELECTION = "no"
    MAXIMIZEBUTTON = "no"
    MINIMIZEBUTTON = "no"
    NAVIGABLE = "no"
    CONTEXTMENU = "no"
    >


    <style type="text/css">
    ..bluetext {font-family: Comic Sans MS; font-size: 10pt; color:
    blue;text-decoration: none;cursor: default;}
    ..redtext {font-family: Comic Sans MS; font-size: 10pt; color: red;text-
    decoration: none;cursor: default;}
    ..whitetext {font-family: Comic Sans MS; font-size: 10pt; color:
    white;text-decoration: none;cursor: hand;}
    </style>


    </head>

    <SCRIPT Language="VBScript">
    Sub Window_Onload


    CitrixPN.style.visibility="hidden"
    VisionAPP.style.visibility="hidden"

    strComputer = "."
    On Error Resume Next
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root
    \cimv2")
    Set colInstalledPrinters = objWMIService.ExecQuery _
    ("Select * from Win32_Printer")
    For Each objPrinter in colInstalledPrinters
    if (objPrinter.Attributes AND 4) = 4 then _
    DataArea.InnerHTML = "<p class='redtext'>" & objPrinter.Name & "</
    p>"
    Next

    Set objNet = CreateObject("WScript.NetWork")
    UserName.InnerHTML = "<p class='redtext'>" & objNet.UserName & "</
    p>"

    Set objNet = CreateObject("WScript.NetWork")
    ComputerName.InnerHTML = "<p class='redtext'>" & objNet.ComputerName
    & "</p>"

    set wsh = WScript.CreateObject ("WScript.Shell")
    Select Case LCase(objNet.UserName)

    Case "test"
    CitrixPN.style.visibility="visible"
    VisionAPP.style.visibility="visible"

    End Select

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root
    \cimv2")

    Set colAdapters = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled =
    True")

    n = 1

    For Each objAdapter in colAdapters
    If Not IsNull(objAdapter.IPAddress) Then
    For i = 0 To UBound(objAdapter.IPAddress)
    IPSpan.InnerHTML = "<p class='redtext'>" & objAdapter.IPAddress(i)
    & "</p>"
    Next
    End If

    n = n + 1

    Next

    End Sub
    </SCRIPT>

    <SCRIPT LANGUAGE="VBScript">
    Sub VisionAPPRDP
    On Error Resume Next
    set wshshell = CreateObject("WScript.Shell")
    wshshell.run """C:\Program Files\visionapp\visionapp Remote Desktop
    \vrd.lnk""", 1, FALSE
    End Sub

    Sub PrattPN
    On Error Resume Next
    set wshshell = CreateObject("WScript.Shell")
    wshshell.run "C:\Progra~1\Citrix\ICACli~1\pn.exe /PN:""PWCS Farm""",
    1, FALSE
    End Sub

    Sub ExitProgram
    window.close()
    End Sub

    </SCRIPT>

    <body topmargin="0" leftmargin="0" rightmargin="0" bgcolor="#C0C0C0">

    <div id="TimeHeader" align="center" style="background-color:blue">
    <table border="0" width="100%" class="blutest" height="10">
    <tr>
    <td align="center" width="100%">
    <script language="javascript">
    function det_time(){
    var d = new Date();
    var dstr = d.toLocaleString();
    document.getElementById('time').innerHTML = dstr;
    }
    </script>
    <div id="time" name="time" style="font-family:comic sans ms;font-
    size:11pt;color:white;font-weight:normal;text-align:CENTER;"><br></
    div>
    <script language="javascript">
    det_time();
    setInterval("det_time()", 1000);
    </script>
    </td>
    </tr>
    </table>
    </div>

    <div id="Header" align="center" style="background-color:yellow">
    <table border="0" width="100%" class="bluetext">
    <tr>
    <td align="right" width="56%">
    Current Default Printer is:
    </td>
    <td align="left" width="44%">
    <span id = "DataArea"></span>
    </td>
    </tr>
    <tr>
    <td align="right" width="56%">
    Current Username is:
    </td>
    <td align="left" width="44%">
    <span id = "UserName"></span>
    </td>
    </tr>
    <tr>
    <td align="right" width="56%">
    Current Computer Name is:
    </td>
    <td align="left" width="44%">
    <span id = "ComputerName"></span>
    </td>
    </tr>
    <tr>
    <td align="right" width="56%">
    Current IP Address is:
    </td>
    <td align="left" width="44%">
    <span id = "IPSpan"></span>
    </td>
    </tr>
    </table>
    </div>

    <div id="TimeFooter" align="center" style="background-color:blue">
    <table border="0" width="100%" class="blutest">
    <tr>
    <td align="center" width="100%" height="10">
    </td>
    </tr>
    </table>
    </div>
    <br>

    <div id="buttons" align="center">
    <button style="background-color:blue" class="whitetext"
    name="CitrixPN" onclick="PrattPN" style="width: 258; height:
    26">Citrix Program Neighborhood</button><p>
    <button style="background-color:blue" class="whitetext"
    name="VisionAPP" onclick="VisionAPPRDP" style="width: 258; height:
    26">VisionAPP RDP</button><p>
    <button style="background-color:blue" class="whitetext"
    name="CloseWindow" onclick="ExitProgram" style="width: 258; height:
    26" >Close</button><p>
    <br>
    </div>

    </body>
    </html>

    <script language="vbscript">
    'Option Explicit
    PositionWindow()
    Sub PositionWindow()
    Dim WindowWidth, WindowHeight, LeftPos, TopPos
    WindowWidth = 375
    WindowHeight = 500
    LeftPos = (screen.availWidth - WindowWidth) / 2
    TopPos = (screen.availHeight - WindowHeight) / 2
    window.resizeTo WindowWidth, WindowHeight
    window.moveTo LeftPos, TopPos
    End Sub
    </script>

    <script type="text/javascript">
    function startProg(myPath)
    {
    var WshShell = new ActiveXObject("wscript.shell");
    WshShell.Run("\""+myPath);
    }
    </script>

    ---------------------------------------------------------------------------------------------------------------------------

    thanks for pointing out the typo with the hex code for red not being
    correct. I feel like a schmuck now.
    , Aug 13, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bnN2a2V5YW4=?=

    how to apply css class style to web controls

    =?Utf-8?B?bnN2a2V5YW4=?=, Feb 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,662
    Chris Jackson
    Feb 20, 2004
  2. Stefan Siegl
    Replies:
    1
    Views:
    943
    Marrow
    Jul 18, 2003
  3. Ken Varn
    Replies:
    0
    Views:
    416
    Ken Varn
    Apr 26, 2004
  4. sonic
    Replies:
    5
    Views:
    261
    Randy Webb
    Jul 11, 2006
  5. pt36

    apply fade effect on innerHTML

    pt36, Aug 5, 2008, in forum: Javascript
    Replies:
    4
    Views:
    132
Loading...

Share This Page