#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2011
    Posts
    1
    Rep Power
    0

    Problems using vbscript InnerHTML in ASP


    I am attempting to have an ASP page load a InnerHTML vbscript when loading to check for the presence of a file on the computer opening the web page. I am attempting to use innerHTML to display an extra cell in a table to display a link to allow the viewer to install the file if the script does not see it. I am getting no results (blank screen) with this and can't say that I am a great coder. I have removed alot of propriertary information, so if some of the code seems strange, that is why. Any help is appreciated.

    Code:
    <html>
    	<head>
    		<base target="_top">
    		<link href="includes/Styles.css" rel="stylesheet" type="text/css">
    		<script language="vbscript">
    		  '==========================================================================
    		  Function FileCheck()
    		    Set objFSO = CreateObject("Scripting.FileSystemObject")
    		    DataArea.InnerHTML = ""
    			strHTML = "<table WIDTH='100%' CellPADDING='0' CELLSPACING='0' BORDER='0' BGCOLOR='#d6ecd8'>"
    			strHTML = strHTML & "  <tr>"
    			If objFSO.FileExists("C:\directory\file.txt") Then
    				strHTML = strHTML & "    <td bgcolor='#5e6a71' valign='middle' align='center' colspan='3' style='height: 20px'>"
    				strHTML = strHTML & "      <p class='small-white-title1'>Title</p>"
    				strHTML = strHTML & "    </td>"
    			Else
        			             strHTML = strHTML & "    <td bgcolor='#FBFAAE' valign='middle' align='center' colspan='3' style='height: 20px'>"
        			             strHTML = strHTML & "      <p style='vertical-align: middle' width='100%'><a href='' onclick='FileInstall' style=' font-family: Arial, Helvetica, sans-serif; font-size: x-small; color: #000000'><img src='images/title_install_icon.jpg' /> Click to install File.</a></p>"
        			             strHTML = strHTML & "	 </td>"
        			             strHTML = strHTML & "	 </tr><tr>"
        			             strHTML = strHTML & "	 <td BGCOLOR='#5e6a71' VALIGN='middle' ALIGN='center' COLSPAN='3' style='height: 20px'>"
        			             strHTML = strHTML & "	   <p class='small-white-title1'>Title</p>"
        			             strHTML = strHTML & "    </td>"
        		             End If
    			strHTML = strHTML & "  </tr><tr bgcolor='#0046ad' height='20'>"
    			strHTML = strHTML & "	<td width='25%'>"
    			strHTML = strHTML & "	</td>"
    			strHTML = strHTML & "	<td width='50%' align='center'>"
    			strHTML = strHTML & "	</td>"
    			strHTML = strHTML & "	<td width='25%'>"
    			strHTML = strHTML & "	</td>"
    			strHTML = strHTML & "  </tr>"
    			strHTML = strHTML & "</table>"
    			DataArea.InnerHTML = strHTML
    		  End Function
    		  '==========================================================================
    		  Function Fileinstall()
    			On Error Resume Next
    			Set sho = CreateObject("WScript.Shell")
    			err.clear
    					sho.Run "xcopy /i /y \\server\share$\file.txt C:\directory\"
    		  End Function
    		  '==========================================================================		  
    		</script>
    	</head>
    	<body onload="FileCheck()" topmargin="2" leftmargin="2" tabindex="-1">
    	   <div>
                        <span id="DataArea"></span>
                    </div>
       </body>
    </html>
  2. #2
  3. No Profile Picture
    Stumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,409
    Rep Power
    4538
    You question seems to be entirely about client-side vbscript. My first recommendation is you use javascript for browser code, vbscript isn't universally supported.

    Other guess, using the filesystem object on the client machine may be prevented by browser security settings. I don't know, I've never tried such code.

    You may get better results in a browser-related forum, asp is server-side code.
    ======
    Doug G
    ======
    It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi

IMN logo majestic logo threadwatch logo seochat tools logo