在 html 中显示 .txt 文件(没有 php 或 javascript)(更新)

发布于 2024-09-26 10:10:36 字数 425 浏览 1 评论 0原文

我想在 html 文件中显示 .txt 文件的上下文。

我知道使用 PHP 或 javascript 会很容易,但是,为了让您了解上下文,我正在为 Facebook 页面(而不是应用程序)构建一个内容管理员。

Facebook FBML 是静态的,不允许使用 php 和非常有限的 javascript。

第一个问题是这是否可能(通过谷歌搜索找不到任何像样的答案),第二个问题是显而易见的方法。

编辑:我看到这个问题 是否可以在静态 FBML 中使用 JavaScript 或 PHP?

这会改变 mattbasta 的答案吗?

I want to display the context of a .txt file in an html file.

I know this would be very easy with PHP or javascript, but, to put you in context, I am building a content administrator for a Facebook page (Not app).

Facebook FBML is static and doest allow php and VERY limited javascript.

The first question would be if this is even possible (couldn´t find any decent answers by googling), and the second is the obvious how.

EDIT: I saw this question Is it possible to use JavaScript or PHP in static FBML?

does this change mattbasta´s answer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

椒妓 2024-10-03 10:10:36

确实如此!您可以使用 FBML 创建返回到服务器的 AJAX 请求并拉入 TXT 文件。您基本上可以通过 AJAX 加载任何内容,否则只需轮询 URL 即可加载。看看这个:

http://developers.facebook.com/docs/fbjs#ajax

在 FBJS 中将 TXT 文件作为字符串拉入后,只需将该字符串分配给一个元素即可。

这应该能让你继续前进。祝你好运!

编辑

此外,作为记录,您可以从 PHP(或任何其他语言)输出 FBML 以创建动态 FBML 页面。只需以与从 PHP 脚本编写 HTML 相同的方式编写 FBML,它就会完全按照您期望的方式工作!

编辑 2

您可以执行类似以下操作来创建 FBML 页面:

<!-- FBML code here -->
<?php
echo file_get_contents("my_txt_file.txt");
?>
<!-- more FBML -->

只需将 Facebook 指向该 PHP 文件,它就会使用 PHP 生成的 FBML。

It sure is! You can use FBML to create an AJAX request back to your server and pull the TXT file in. You can basically load anything over AJAX that you otherwise would be able to load by just polling a URL. Check this out:

http://developers.facebook.com/docs/fbjs#ajax

Once you pull in the TXT file as a string in FBJS, just assign the string to an element and you're good as gold.

That should get you going. Good luck!

EDIT

Also, for the record, you can output your FBML from PHP (or any other language, for that matter) to create a dynamic FBML page. Just write FBML in the same way you would write HTML from your PHP script and it'll work exactly how you would expect it to!

EDIT 2

You can do something like this to create your FBML page:

<!-- FBML code here -->
<?php
echo file_get_contents("my_txt_file.txt");
?>
<!-- more FBML -->

Just point Facebook at that PHP file and it'll use the FBML that the PHP generates.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文