【发布时间】:2012-05-24 12:22:06
【问题描述】:
我的简单代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script src="jquery.js"></script>
<script type="text/javascript">
$(function(){
$.get("http://www.facebook.com",function(data){
alert(data);});
});</script></head>
<body>
</body>
</html>
它应该提醒 facebook 内容,但它没有这样做
更新
现在我正在使用 php
<?php
$str=file_get_contents("http://www.facebook.com");
echo strip_tags(htmlspecialchars($str));
?>
为什么不删除标签?
【问题讨论】:
-
这是跨域请求,无法使用。只有像 JSONP 这样的请求才会起作用。
-
因为您使用
htmlspecialchars()对它们进行了编码,因此不再是标签而是 HTML 实体。 -
但是当删除 htmlsecialchars 并只使用 strip_tag 时,它向我展示了很多 js 代码
标签: php javascript jquery ajax facebook