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

  • Home
  • SEARCH
  • 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 6898479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:18:05+00:00 2026-05-27T07:18:05+00:00

I have two nearly identical functions, but I’m not sure how I can refactor

  • 0

I have two nearly identical functions, but I’m not sure how I can refactor this so they can share the same logic.

function Content_chkClick(obj) {
    var frame = $('#iFM')[0];

    if (frame.contentWindow.Content_chkClick) {
        frame.contentWindow.Content_chkClick(obj);
    } else {
        $('.TabContent', frame.contentWindow.document).each(function () {
            var frame = this;
            if (frame.contentWindow.Content_chkClick) {
                frame.contentWindow.Content_chkClick(obj);
            }
        });
    }
}

function Content_invokeClickEvent(id) {
    var frame = $('#iFM')[0];

    if (frame.contentWindow.Content_invokeClickEvent) {
        frame.contentWindow.Content_invokeClickEvent(id);
    } else {
        $('.TabContent', frame.contentWindow.document).each(function () {
            var frame = this;
            if (frame.contentWindow.Content_invokeClickEvent) {
                frame.contentWindow.Content_invokeClickEvent(id);
            }
        });
    }
}

Ultimately, what I want to be able to do is just have something like

function Content_chkClick(obj) {
    someCommonFunction(Content_chkClick, obj);
}
function Content_invokeClickEvent(id) {
    someCommonFunction(Content_invokeClickEvent, id);
}
  • 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-05-27T07:18:06+00:00Added an answer on May 27, 2026 at 7:18 am
    function Content_xClick(fname, obj) {
        function callIfPossible(frame) { 
            if (frame.contentWindow[fname]) {
                frame.contentWindow[fname](obj);
                return true;
            }
        }
    
        if (!callIfPossible($('#iFM')[0])) {
            $('.TabContent', $('#iFM')[0].contentWindow.document).each(function () {
                callIfPossible(this);
            });
        }
    }
    

    Ultimately, you should be able to do is just something like

    function Content_chkClick(obj) {
        Content_xClick("Content_chkClick", obj);
    }
    function Content_invokeClickEvent(id) {
        Content_xClick("Content_invokeClickEvent", id);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two nearly identical queries operating on essentially the same fields in two
I have two nearly identical javascript functions that are used to initiate a jquery
So, lets say I have two nearly identical classes in C# and Ruby: C#
I have two profiles that are nearly identical. Rather than duplicating the configuration in
If I have two nearly identical classes Animal and AnimalViewModel and an expression tree
I'm working on some legacy Django code. I have two nearly-identical views: @login_required def
I have two identical tables and need to copy rows from table to another.
I have two webapplication, one is a simple authenticationsite which can authenticate the logged
I have a couple classes that have nearly identical code. Only a string or
I ran into the problem that two drives connected at nearly the same time

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.