我在 jQuery 中编写了一个代码,它执行以下操作:
- 通过 Facebook 连接
- 点击喜欢按钮
检查是否在 Facebook 上喜欢并显示内容,如果不喜欢,请要求喜欢
<script> $('#loginfb').click( function() { FB.login(function(response) { if (response.authResponse) { var logstatus="logged in"; FB.api('/me', function(response) { console.log('Good to see you, ' + response.name + '.'); }); $('#loginfb').empty(); $('#loginfb').append('<p>Logged In to Facebook</p>'); console.log('Welcome! Fetching your information.... '); var url = 'http://facebook.com/bitslabo'; $('#fblikeblock').html('<div id="pleaselike">like!</div><fb:like id="fbLike" href="'+url+'" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>'); FB.XFBML.parse(document.getElementById('fblikeblock')); } else { console.log('User cancelled login or did not fully authorize.'); } },{perms:"friends_likes,user_likes"}); }); $('#getlogin').click( function() { FB.getLoginStatus(function(response) { var page_id = "[PAGE ID]"; if (response && response.authResponse) { var user_id = response.authResponse.userID; var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+" and uid="+user_id; FB.Data.query(fql_query).wait(function(rows) { if (rows.length == 1 && rows[0].uid == user_id) { console.log("LIKE"); $('#container_notlike').hide(); $('#container_like').show(); } else { console.log("NO LIKEY"); $('#container_like').hide(); $('#container_notlike').show(); } }); } else if (response.status === 'not_authorized') { // the user is logged in to Facebook, // but has not authenticated your app alert('Please click "Log in to Facebook"'); } else { alert('Please click "Log in to Facebook"'); // the user isn't logged in to Facebook. } }); }); </script>
问题是我正在使用的 CMS(magento 1.5)上到处都是prototype.js,并且存在 jQuery 与 Prototype 冲突,其中 jQuery 覆盖了 Prototype 并禁用了网站的所有功能。
所以,我想,这里有两个问题:
- 如何让 jQuery 脚本运行而不影响原型脚本?
- 如何在原型中编写我上面描述的相同内容?
我希望这是有道理的!提前致谢!