在一个项目上工作,其中一个网页将显示一个人员列表(具体来说,还有一个尚未找到的毕业班人员列表).我不想手动更新表格中的这些列表,这是一种骨干的Web 1.0方式,我想提取名称的提交列表,将它们转换为简单的.txt列表,然后在网页上显示该列表.
到目前为止,执行此操作的简单方法是使用iframe元素...唯一的事情是,我不能(或不知道如何)将任何文本样式应用于iframe的内容.我已经发布了一个我能够在这里完成的示例:http://dongarber.com/test//helpus-iframetest.html
默认字体是快递,客户端可能不会太热衷于它.有没有更好的方法来做到这一点,那不需要ASP.NET或数据库?
#list p {
font: arial;
font-size: 14px;
}
...
<p>Help us locate all of our classmates from the High School class of 1961. If you know where they live or their e-mail addresses contact the Reunion Committee.</p>
<p> </p>
<div id="list"><p><iframe src="missingmen.txt" width=200 height=400 frameborder=0 ></iframe></p></div>
</div>
Run Code Online (Sandbox Code Playgroud)
thi*_*dot 30
简单的方法:
missingmen.txt为missingmen.html.missingmen.html:<link href="txtstyle.css" rel="stylesheet" type="text/css" />txtstyle.css,并在其中添加如下行:html, body {font-family:Helvetica, Arial, sans-serif}nik*_*tko 14
在更新的浏览器中,像下面这样的代码可能就足够了。
<object data="https://www.w3.org/TR/PNG/iso_8859-1.txt" width="300" height="200">
Not supported
</object>Run Code Online (Sandbox Code Playgroud)
小智 11
我发现,如果我尝试别人说不起作用的事情,那就是我学到的最多.
<p> </p>
<p>README.txt</p>
<p> </p>
<div id="list">
<p><iframe src="README.txt" frameborder="0" height="400"
width="95%"></iframe></p>
</div>
Run Code Online (Sandbox Code Playgroud)
这对我有用.我使用了我在样式表中设置的黄色背景颜色.
#list p {
font: arial;
font-size: 14px;
background-color: yellow ;
}
Run Code Online (Sandbox Code Playgroud)
woo*_*586 10
如果您只想将文件内容放到屏幕上,可以尝试使用PHP.
<?php
$myfilename = "mytextfile.txt";
if(file_exists($myfilename)){
echo file_get_contents($myfilename);
}
?>
Run Code Online (Sandbox Code Playgroud)
这是我使用的代码:
<?php
$path="C:/foopath/";
$file="foofile.txt";
//read file contents
$content="
<h2>$file</h2>
<code>
<pre>".htmlspecialchars(file_get_contents("$path/$file"))."</pre>
</code>";
//display
echo $content;
?>
Run Code Online (Sandbox Code Playgroud)
请记住,如果用户可以修改 $path 或 $file(例如通过 $_GET 或 $_POST),他/她将能够看到您的所有源文件(危险!)
| 归档时间: |
|
| 查看次数: |
191643 次 |
| 最近记录: |