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 8472867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:11:38+00:00 2026-06-10T17:11:38+00:00

Hello I have a function to perform actions but name of the function is

  • 0

Hello I have a function to perform actions but name of the function is inside a variable…

below code will get the URL’s hashed part example: #JHON and remove # and store it inside URLHASH variable..example: JHON

  var urlhash = document.location.hash;
  urlhash = urlhash.replace(/^.*#/, '');

always there is a function name from that value inside variable and i want to call value inside that variable as a function name

  window.onload=function() {
    Value inside URLHASH variable should run as a name of a variable. example: jhon();
  };

Is it possible ? I tried some codes but it calls variable name as a function not value inside the variable..help me..

  • 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-10T17:11:40+00:00Added an answer on June 10, 2026 at 5:11 pm

    You can access attributes of objects as if they are array indexes, so for example, you could run getElementById this way:

    document["getElementById"]("#myid");
    

    so& if you know beforehand of which object the function will be a member, you can access it this way. functions in the global scope are methods of the window object. However, if the hash may contain expressions like #document.write(), you would have to do some parsing. it could work like this

    window.onload=function() {
        var urlhash = document.location.hash, current_element = window;
        urlhash = urlhash.replace(/^.*#/, '');
        elements = urlhash.split(".");
        for(var i=0; i<elements.length; i++){
            current_element = current_element[elements[i]];
        }
        //execute the actual function
        current_element();
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a hello function and it takes n arguments (see below code). def
Hello I have next function, what always return null as result, but service calling
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
Hello guys, I have been trying to implement the DSUM function but failed to
Hello I have a php code which by echo calls the javascript function expand(txt)
hello i want i have function to get paragraph of selected text. this is
Hello I have this function that will delete all the empty fields in the
Hello guys I have a function inside a utility class which returns the current
I have a function: # utils.py def hello(name='World'): # Detect where I'm being called
Hello I have an example that works properly: $(function() { $(#treegrid).jqGrid({ url: 'tree2.json', datatype:

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.