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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:50:12+00:00 2026-05-26T22:50:12+00:00

I have a program that allows a user to type JavaScript in a textbox,

  • 0

I have a program that allows a user to type JavaScript in a textbox, and it executes in an HTML viewer or iframe. There is a drop down with options such as “Insert Image”, which inserts

var $'Image Name' = document.createElement('img');
$'Image Name'.src = $'Image URL';
$'Image Name'.style.position = 'absolute';
document.body.appendChild($'Image Name');

into the textbox. I want the user to select the option “Insert Image”, and have a dialog go through each $'', and ask for something to replace them with, so for the first $'Image Name', prompt the user for a variable name, and then replace("$'Image Name'", userText) so all the $'Image Name's get replaced and the user isn’t prompted for the same one again. Any ideas? I have this replace:

replace(/^\$\"|\'.$\"|\'/gi, function ($string) { return prompt($string);});

but it matches the quotes, not the text inside the quotes, and I don’t even know regex, if you can solve the regex, I can figure out the rest.

  • 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-26T22:50:13+00:00Added an answer on May 26, 2026 at 10:50 pm

    I guess you want something like this:

    replace(/\$'([^']+)'/g, function (s, contents) { return prompt(contents); });
    

    though I should mention that this will misbehave if a single-quoted string happens to end with a dollar-sign, or if a double-quoted string happens to contain $', or whatnot; do you need to be able to handle these sorts of cases? (It’s not obvious from your question whether you completely control the contents of the textarea, or whether it’s something your users might be editing.)

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

Sidebar

Related Questions

I have a program that allows a user to type java code into a
I have a program that allows the user to enter a level number, and
I have created the output for a program that allows a user to input
I have a program that allows the user to execute SQL scripts. I have
I have a program that allows the user to use a few dropdowns to
I have a program that only allows one instance of itself to run. I
I have a program that creates a JFrame and makes it visible. Is there
I'm doing a magicsquare program that allows a user to input numbers >0 to
I made a simple program that allows the user to pick a number of
I'd like to write a python program that allows the user to key an

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.