简体   繁体   English

Chrome Javascript书签问题

[英]Chrome Javascript Bookmarklet Problem

I made this simple bookmarklet to get the Facebook id from a Facebook user's profile. 我做了这个简单的书签,以便从Facebook用户的个人资料中获取Facebook ID。

var fb_idsource=document.getElementById("profile_action_send_message").href;
var fb_userid=fb_idsource.match(/\d+/g);
alert(fb_userid);

Open someone's facebook profile with a send "Message" button at top right corner. 使用右上角的发送“消息”按钮打开某人的Facebook个人资料。 It will work if you paste it and run via Google Chrome developer console, but not working when used as bookmarklet by adding "javascript: " prefix. 如果您将其粘贴并通过Google Chrome开发者控制台运行,它将可以使用,但是当通过添加“ javascript:”前缀用作书签时,则不能使用。

Any ideas how to make it work?? 任何想法如何使其工作? Thx for any advice. 感谢任何建议。

Drag and drop this into your bookmark bar, works great! 将其拖放到书签栏中,效果很好!

http://jsfiddle.net/wesbos/Evzek/ http://jsfiddle.net/wesbos/Evzek/

<a href='javascript:(function(){var fb_idsource=document.getElementById("profile_action_send_message").href; var fb_userid=fb_idsource.match(/\d+/g); alert(fb_userid);})();'>Get ID</a>

Ps great idea - will use this for sure! ps好主意-一定会使用它!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM