开发者

Load LinkedIn member profile by inserting javascript with Jquery

开发者 https://www.devze.com 2023-03-23 12:44 出处:网络
I am trying to display LinkedIn member profiles by having a user enter in their public profile URL then loading that profile using JQuery. When they enter in www.linked.in/com/in/theirprofile, I am ca

I am trying to display LinkedIn member profiles by having a user enter in their public profile URL then loading that profile using JQuery. When they enter in www.linked.in/com/in/theirprofile, I am calling this:

$(document).ready( function(){
    $("#linkedin_field").blur( function(){
        $("#profile").html('<script type="IN/MemberProfile" data-id="' + $("#linkedin_开发者_运维知识库field").val() + '" data-format="inline"><\/script>')
    });
});

This does insert the javascript into the #profile div but it doesn't display the member's profile. How can I get the profile to load when I insert the new javascript?

Note that this page is successfully loading the profile when I include the javascript at the beginning with a valid user profile.


It takes one line for LinkedIn to parse the rendered javascript, so all that's necessary is:

$(document).ready( function(){
    $("#linkedin_field").blur( function(){
        $("#profile").html('<script type="IN/MemberProfile" data-id="' + $("#linkedin_field").val() + '" data-format="inline"><\/script>')
    });
    IN.parse(document.getElementById("profile"))
});


I'm going to guess that "IN/MemberProfile" is for a JavaScript-based widget provided by LinkedIn, as I don't see any other way you could expect that code to work.

If that's the case, the LinkedIn widget likely only runs on the first page load. Thus, injecting a script tag still isn't going to get the LinkedIn JavaScript to re-execute.

If you inject the LinkedIn JavaScript file after the widget code it will likely re-execute, or you could attempt to find the function in the LinkedIn JavaScript that renders their widgets and re-call it.

0

精彩评论

暂无评论...
验证码 换一张
取 消