Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8869877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:35:06+00:00 2026-06-14T17:35:06+00:00

If I write code in the JavaScript console of Chrome, I can retrieve the

  • 0

If I write code in the JavaScript console of Chrome, I can retrieve the whole HTML source code by entering:

  var a = document.body.InnerHTML; alert(a); 

For fb_dtsg on Facebook, I can easily extract it by writing:

  var fb_dtsg = document.getElementsByName('fb_dtsg')[0].value;

Now, I am trying to extract the code “h=AfJSxEzzdTSrz-pS” from the Facebook Page. The h value is especially useful for Facebook reporting.

How can I get the h value for reporting? I don’t know what the h value is; the h value is totally different when you communicate with different users. Without that h correct value, you can not report. Actually, the h value is AfXXXXXXXXXXX (11 character values after ‘Af’), that is what I know.

Do you have any ideas for getting the value or any function to generate on Facebook page.

The Facebook Source snippet is below, you can view source on facebook profile, and search h=Af, you will get the value:

  <code class="hidden_elem" id="ukftg4w44">
<!-- <div class="mtm mlm">
  ...
   ....
  <span class="itemLabel fsm">Unfriend...</span></a></li>
  <li class="uiMenuItem" data-label="Report/Block...">
  <a class="itemAnchor" role="menuitem" tabindex="-1" href="/ajax/report/social.php?content_type=0&amp;cid=1352686914&amp;rid=1352686914&amp;ref=http%3A%2F%2Fwww.facebook.com%2      F%3Fq&amp;h=AfjSxEzzdTSrz-pS&amp;from_gear=timeline" rel="dialog">
  <span class="itemLabel fsm">Report/Block...</span></a></li></ul></div>

  ...
   ....
  </div> -->
  </code>

Please guide me. How can extract the value exactly?

I tried with following code, but the comment block prevent me to extract the code. How can extract the value which is inside comment block?

 var a = document.getElementsByClassName('hidden_elem')[3].innerHTML;alert(a);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:35:08+00:00Added an answer on June 14, 2026 at 5:35 pm

    Here’s my first attempt, assuming you aren’t afraid of a little jQuery:

    // http://stackoverflow.com/a/5158301/74757
    function getParameterByName(name, path) {
        var match = RegExp('[?&]' + name + '=([^&]*)').exec(path);
        return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
    }
    
    var html = $('.hidden_elem')[0].innerHTML.replace('<!--', '').replace('-->', '');
    var href = $(html).find('.itemAnchor').attr('href');
    var fbId = getParameterByName('h', href); // fbId = AfjSxEzzdTSrz-pS
    

    Working Demo

    EDIT: A way without jQuery:

    // http://stackoverflow.com/a/5158301/74757
    function getParameterByName(name, path) {
        var match = RegExp('[?&]' + name + '=([^&]*)').exec(path);
        return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
    }
    
    var hiddenElHtml = document.getElementsByClassName('hidden_elem')[0]
        .innerHTML.replace('<!--', '').replace('-->', '');
    
    var divObj = document.createElement('div');
    divObj.innerHTML = hiddenElHtml;
    
    var itemAnchor = divObj.getElementsByClassName('itemAnchor')[0];
    var href = itemAnchor.getAttribute('href');
    
    var fbId = getParameterByName('h', href);
    

    Working Demo

    I’d really like to offer a different solution for “uncommenting” the HTML, but I stink at regex 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me how to write javascript code that removes everything after the
How to write this JavaScript code without eval? var typeOfString = eval(typeof + that.modules[modName].varName);
Is there a c# library that can help to write and indent Javascript code.
Possible Duplicate: Is Chrome's JavaScript console lazy about evaluating arrays? I write next js
I wanted to see if I can write some c# code in a javascript-fashion
I use Aptana Studio to code JavaScript. When I write string with </ ,
i am writing javascript code on nodepad++,i am at beginner level and write just
I want a piece of Javascript code or some guidance on how to write
I tried to write a function to check key code with JavaScript. It's working
I want to write the following C# code equivalent in JavaScript/jQuery (x == 0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.