21,886
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html>
<head></head>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function (){
$('#xxxxx').click(function (){
var t = $(this).attr('title');
var h = $(this).html();
var r = $(this).attr('rel');
//字符串连接,
var u = r + '&testTitle='+ t + '&testHtml=' + h;
alert(u);
});
})
</script>
<body>
<a href="javascript:;" rel="http://www.example.com/?title=HypeLinkTitle" title="testTitle" id="xxxxx">testHtml</a>
</body>
</html>
[/quote]
这种 onclick + rel 的形式,百度蜘蛛可以正常获取链接并爬过去么?
<!DOCTYPE html>
<html>
<head></head>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function (){
$('#xxxxx').click(function (){
var t = $(this).attr('title');
var h = $(this).html();
var r = $(this).attr('rel');
//字符串连接,
var u = r + '&testTitle='+ t + '&testHtml=' + h;
alert(u);
});
})
</script>
<body>
<a href="javascript:;" rel="http://www.example.com/?title=HypeLinkTitle" title="testTitle" id="xxxxx">testHtml</a>
</body>
</html>
[/quote]
谢谢。也感谢 fire53。
获取这个我会啊,现在的问题是,我要如何把这取得的值传回到php?
想实现的作用是,点击这个链接,php后台就根据这个链接超本文从数据库读取相关的文章。
其他都弄好了,现在就差如何将获取的超文本传给php了。
链接的形式是
<a href="http://www.example.com/HypeLink8/" title="超链接标题8" id="hplink">超链接标题8</a>
<!DOCTYPE html>
<html>
<head></head>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function (){
$('#xxxxx').click(function (){
var t = $(this).attr('title');
var h = $(this).html();
var r = $(this).attr('rel');
//字符串连接,
var u = r + '&testTitle='+ t + '&testHtml=' + h;
alert(u);
});
})
</script>
<body>
<a href="javascript:;" rel="http://www.example.com/?title=HypeLinkTitle" title="testTitle" id="xxxxx">testHtml</a>
</body>
</html>