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

The Archive Base Latest Questions

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

Rewrote the entire question because evidently it was too vague I have HTML, this

  • 0

Rewrote the entire question because evidently it was too vague

I have HTML, this HTML needs to be processed by Javascript before I send it through E-mail.

In other words, I need to run Javascript on HTML during PHP runtime.

(Fake) example to illustrate my point:

<?
$html = run_js_html($input,'myscript.js');
mail('target@email.com','Subject',$html);
?>

$input contains the input HTML
myscript.js contains some JS functionality
run_js_html should be a function that runs the script on the html, and then returns the new HTML after javascript.

Is this possible? One way I thought maybe could work is do some kind of HttpRequest through PHP to a PHP file that includes the input HTML and runs the Javascript on it.

  • 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-26T00:12:46+00:00Added an answer on May 26, 2026 at 12:12 am

    Step number 3, if you insist in using jQuery, has to be done on the client side unless you are using server-side JavaScript, which you’re not, judging from the PHP tag.

    Your options are:

    1. Have a client (for example, the person sending the email) execute the JavaScript. You could do this in a hidden iframe if you don’t want it to be visible. On the other hand, you might want to make this a feature: Before sending, show the user a preview pane. The submit button could be used to submit the final HTML (after jQuery’s manipulation).
    2. Install graphical web browser with JavaScript capabilities on the server and capture the output. Probably to much trouble for something like this.
    3. Dump jQuery for this purpose and see if you can use PHP’s DOMDocument. phpquery abstracts a lot away and has a syntax similar to jQuery.

    But do you really want to do this? Couldn’t you do something like this?

    function send_some_email()
    {
        ob_start();
        include("my_email.php");
        $content = ob_get_clean();
    }
    // file my_email.php:
    <?php 
        $size = 3;
        $length = strlen($title);
        if($length > 50)
            $size = 1;
        elseif($length > 30)
            $size = 2;
    ?>
    <body>
        <?php echo sprintf('<font size="%d">%s</font>', $size, $title); ?>
        <br>
        Hello World.
    </body>
    

    While judging a string’s length by the number of characters is not very reliable, it is an easy implementation. You can also compute the approximate length of the string by:

    1. Make or find a function that takes into account letters like ‘i’ (not wide) and ‘M’ (wide).
    2. Calculate the width of a string with imagettfbbox().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following form and javascript function on my web page. This is
So I rewrote my paths to something like: URL/really/nice/paths/ using mod_rewrite rules like this:
url.rewrite-once = ( .*\.(js|ico|gif|jpg|png|css|html)$ => $0, ^/([^?]*)(\?.*)?$ => /$1.php/$2, ) This is what I
If I use mod_rewrite to control all my 301 redirects, does this happen before
I have a quick question i hope you guys can answer, i've got a
(Not sure is this has been discussed before ...) When building SQL for category
My question is: why do primitive types have to be wrapped in an object,
History of the problem This is continuation of my previous question How to start
Before asking my question I would like to explain little about my architecture.My data
I'm redirecting an entire folder into the duplicate folder above it. I have mod_rewrite

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.