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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:03:28+00:00 2026-06-18T14:03:28+00:00

I have a popup system in my project. With a name, for example ‘addnews’,

  • 0

I have a popup system in my project. With a name, for example ‘addnews’, it knows which popup content to add and which script is necessary to handle the form. Up until now after completion I always did the same thing. Now, in some cases, I want to do something different.

Now I want to add a JavaScript function with that same name, like previous example ‘addnews()’, and check if that function exist. If it does run it, else do the standard things. (1)

Also executing a function with that name as variable doesn’t seem to work. (2)

var functionName = 'addnews';

if (typeof functionName == 'function') { // (1) typeof functionName = string
    window[functionName](); // (2) this doesn't work for me
} else {
    // Do something standard
}

function addnews() {
    // Do something special
}
  • 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-18T14:03:29+00:00Added an answer on June 18, 2026 at 2:03 pm

    If you use this code in a document and it is not loaded complitelly your code will not find the function addnews() because it is not declare before this code.

    Like in the comments: you need to use

    if (typeof window[functionName] == 'function') 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have popup-window in my script. I use window.open, but almost all browsers block
I have a Popup defined like this: <Popup Name=myPopup StaysOpen=True Placement=Bottom PlacementRectangle=0,20,0,20 PlacementTarget={Binding ElementName=myPopupAnchor}>
I have a small popup window like so: using System; using System.Collections.Generic; using System.ComponentModel;
I have a popup system that shows a image when you hover over a
I have set up my site to use the gitter popup system. The javascript
I have implemented MVP pattern in my GXT project. The system registers customers as
I have a popup menu which works as expected. The drag-and-drop functionality on the
I have a popup in my application which is activated by a change in
I have popup searcher in my application which lists the available record as hyperlink.
TL;DR (Short synopsis): I have recreated the admin Add button in my own project.

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.