I'm looking for a minimalistic way to view the contents of my text (.txt) file.
I can call the file with notepad, but I don't want a user to be able to directly edit the file.
Is it possible to show the content in a scrollable popup window? Preferably without the use of javascript.
I created a new sub .hta which I call from my main .hta
Works great except when I convert the sub .hta to a .exe with HTAEdit, it won't open my log file :/ Well that's another issue to solve :)
Here's my sub .hta code:
<head>
<title>Log File Viewer</title>
<HTA:APPLICATION
INNERBORDER="no"
SYSMENU="yes"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
SCROLL="no"
SCROLLFLAT="yes"
SHOWINTASKBAR="no"
CONTEXTMENU="no"
SELECTION="no"/>
</head>
<script language="Javascript">
window.resizeTo(600,450); // Width,Height
window.moveTo(window.screen.width/3,window.screen.height/3);
</script>
<script language="VBScript">
Dim strHTML
Sub Window_OnLoad
logfile = "LOG_" & DatePart("yyyy",Date) & "_" & Right("0" & DatePart("m",Date), 2) & ".txt"
strHTML = ""
strHTML = strHTML & "<div id='list'>"
strHTML = strHTML & "<p><iframe src='logs\" & logfile & "' frameborder='0' height='330' width='100%'></iframe></p>"
strHTML = strHTML & "</div>"
LogViewer.InnerHTML = strHTML
End Sub
Sub ClosePopup
window.close
End Sub
</script>
<body>
<div id="LogViewer"></div>
<center><input type="button" id="Close" value="Close Log Viewer" onclick="VBScript:ClosePopup"></center>
</body>
</html>
Related
I am making a tool for work that generates a new project item on our sharepoint.
On the sharepoint we have a form that needs to be filled in and to identify the textfields of the form I use the IE.Document.All.Item("id").value=value command.
It works in a separate vbs file, but when I try to launch it from hta it blocks at the IE.Documents.All.item command. Does anybody knows how to solve this?
The code looks like the following (language: vbscript):
Sub SendProjectData
Set IE = CreateObject("InternetExplorer.Application")
set WshShell = CreateObject("WScript.Shell")
IE.Navigate "https://sharepointpage"
IE.Visible = true
sleep1 6000 'external defined sleep command'
IE.Document.All.Item("projectid").Value = "projectname"
WshShell.AppActivate "IE"
WshShell.SendKeys "{ENTER}"
End Sub
Mmmh, I work with:
oIe.document.getElementById("testMsgBox").value = "hallo"
or
oIE.document.all.testMsgBox.value = "hallo"
Perhaps that helps, Reinhard
This should work. Tested under Win10 with IE11:
First the HTML test file:
<html>
<head><title>MyInputFile</title></head>
<body>
<h1>IE with Input field</h1>
<input type="text" id="myText" value="Default text" size="20">
</body>
</html>
Now the HTA file to fill out the html File:
<html>
<head>
<title>Hypertext-Application Demo</title>
<HTA:APPLICATION ID="oHTA">
<script language="vbscript">
sub Window_Onload
self.resizeto 500,200
self.MoveTo 50,50
End Sub
Sub fillHta()
myText.value = "New Text"
End Sub
Sub startAndFill()
set wsh = CreateObject("WScript.Shell")
'Set oIE = CreateObject("InternetExplorer.Application")
Set oIE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
oIE.Navigate "d:\MyInputFile.html"
oIE.Visible = true
Do: Loop Until oIE.Busy = False
Do: Loop Until oIE.Document.ReadyState = "complete"
oIe.document.getElementById("myText").value = "New Text" 'use this
x = oIe.document.getElementById("myText").value
oIE.document.all.myText.value = x & "; New Text2" 'or this
End Sub
</script>
</head>
<body bgcolor="#99CCFF">
<p>Simple Demo of Hypertext Applikationen</p>
<input type="button" value="Fill HTA input field" onclick="fillHta()">
<input type="text" id="myText" value="Default text" size="20">
<p><input type="button" value="start and fill IE field" onclick="startAndFill()"> D:\MyInputFile.html</p>
</body>
</html>
Enjoy, Reinhard
I am trying to make a PHP script write into a plain text file. I have done this before and it worked just fine. But it's not working this time for some reason.
Here is the HTML I am using:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="/css/feedback.css" >
<title>Questions, Comments, Suggestions</title>
</head>
<body>
<p class="title">Questions, comments, and suggestions here!</p>
<form method="post" name="userFeedback" action="/submit.php">
<textarea id="comments" placeholder="Leave a comment or review here..."></textarea>
<textarea id="name" placeholder="Your name here"></textarea>
<textarea id="contact" placeholder="Put any means of contact you want to here (optional)"></textarea>
<br>
<input class="enter" type="submit" value="Enter">
</form>
</body>
</html>
All I want to do with this is to print out whatever is entered onto a plain .txt file with PHP 5.3. Here is the code:
$data = ($_POST["comments"] ." || ". $_POST["name"] ." || ". $_POST["contact"]);
$data = strip_tags($data);
$file = "feedback.txt";
$f = fopen($file, "a+");
fwrite($f, $data . "\n" . "\n");
fclose($f);
header ( 'Location: index.html' );
Please remember that I am using 5.3. I'm sure there's a simple error in here somewhere. Can someone help me with this? Thank you in advance!
We got it! Turns out that the PHP $_POST method looks for the "name" attribute and not the "id".
here is my html code
<html>
<title>Results</title>
<body><h1> Here are your results</h1>
<p>Please click the Button to see your result run by Ravi's team.</p>
<form action='index.pl' method='post'>
<input type='submit' value='submit'>
</form>
</body>
</html>
and index.pl is my perl and my subroutine is as follows.
sub my_result{
my $run;
my $dir="/kbio/sraja/BenzoExposedDataSet/database/Output";
my $parsebphtml = "/parse_bphtml.pl";
my $olgacsvfile = "/database/Output/sample.csv";
my #bp=<$dir/*.bp>;
$run ="perl $parsebphtml > $olgacsvfile";
# print "$com\n";
system($run)==0 or my_err("Could not run $run\n");
#printing the table
open(F,"$olgacsvfile") or my_err("Could not open the csv ($olgacsvfile) file");
print "<h2> Average Results </h2>";
print "<table border=1>";
while(my $line=<F>){
print "<tr>";
my #cells= split ',',$line;
foreach my $cell (#cells)
{
print "<td colspan=1>$cell</td>";
}
print "</tr>";
}
print "</table>";
}
So as you see, table is what i need to return to results.html
Any help would be really appreciable.
thanks .
Geet
I don't know how much work you want to do but, if you want to keep it simple give a try at the HTML::Template module. Here is a simple usage example.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<title>A random page</title>
</head>
<body>
<TMPL_VAR NAME=page_content>
</body>
</html>
My perl code contained something like this. Better yet, check the documentation at http://metacpan.org/pod/HTML::Template .
use HTML::Template;
sub my_result {
return $html_string;
}
my $master_template = HTML::Template->new(filename => "Path to html template file");
$master_template->param('page_content' => my_result());
Depending on how far you plan on going with this, I would recommend that you a more advanced templating system such as the one used by the mojolicious framework (http://mojolicio.us/perldoc/Mojo/Template).
Cheers,
MrMcKizzle
I dunno if its a silly mistake but a post/get variable is not being set, while it is supposed to be. Here are the HTML and php code snippets:
<html>
<head>
<title>
Chain Story
</title>
</head>
<body>
<form method="GET" action="check-valid.php">
<textarea name="a" rows="5" cols="50"></textarea>
<input type="submit" value="Add" />
</form>
</body>
</html>
check-valid.php:
<?php
require 'includes/connect.inc.php';
$conn_ref = connect_db('chainstory') or die(mysqli_error());
if(isset($_GET)){
echo 'Get variable set';
if(isset ($_GET['a'])){
$as = $_GET['a'];
$query = "insert into story1 values (1, " . $as . ")";
mysql_query($query, $conn_ref);
}
else{
echo $_GET;
}}
?>
I get the following output:
Get variable set
Notice: Array to string conversion in /home/kevin/Code/php/myWebsite/check-valid.php on line 15
Array
I am coding this in netbeans. Can anyone point me out what mistake im making? :(
Did you try rename the textarea? Longer name , and give id to textarea same the name.
What browser does you use for testing?
I met some problems with input names in IE for example if an input name matches a javascript function name or protected names. Have you a javascript function or variable in your code what's name is a ? Because if the name of the input conflicts with a js var or name IE does not send the input field to the server. (Chrome Firefox and other browsers does)
So I have some html code and it's basically a page with students basic info. Would someone help me or show me how to insert CSV data into the html, so that I don't have to do it manually.. Thanks. Here is a sample code. So, "Student1" , "li.picture1", student1.png, "Student 1" and most importantly the " X sample1" "X sample2" and "Y sample1" "Y Sample2" would be autofilled with csv data..
<div id="Student1">
<div class="toolbar">
<h1>[title]</h1>
Back </div>
<head>
<script type="text/javascript" charset="utf-8">
window.onload = function() {
setTimeout(function(){window.scrollTo(0, 1);}, 100);
}
</script>
<!-- for profile image -->
<style type="text/css" media="screen">
li.picture1 { background: #fff url(images/student1.png) no-repeat !important; }
</style>
<!-- end line customization -->
</head>
<ul class="profile">
<li class="picture1"></li>
<li class="clearfix"><h2>Student 1</h2></li>
</ul>
<ul class="field">
<li class="sep" align="center">Day 1</li>
<li><h3>X Sample1</h3> <p>Y Sample1</a></li>
<li class="sep" align="center">Day 2</li>
<li><h3>X Sample2</h3> <p>Y Sample2</a></li>
</ul>
</div>
Im afraid you will most likely have to do that manually unless you copy it all into excel and delete everything but the key data fields
I can think of two ways to do this. One is to write a program in your favourite programming language which reads the CSV file and combines it with the HTML. Like this: (not real code)
read CSV into $student,$picture...
output to file '<div id="' . $student . '"><div class="toolbar">' etc.
Or open the CSV in excel and put a formula at the end of the line like this
="<div id=""" & a1 & "><div class=""toolbar""> etc.".... & b1 & ....
Note the doubled up quotes inside the strings.