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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:58:39+00:00 2026-06-09T20:58:39+00:00

To follow new cookie legislation, we need to add a JS plugin to clients

  • 0

To follow new cookie legislation, we need to add a JS plugin to clients websites. However, one is proving difficult: pure HTML with a tonne of pages.

Is it possible in any way, shape or form to say:

server request {
    send a php file to inject into a html file sent from the server
}

Or anything vaguely similar?

  • 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-09T20:58:41+00:00Added an answer on June 9, 2026 at 8:58 pm

    I think the simplest way inject custom code into the HTML files without modifying them, is to add an additional layer of processing. It will slightly (probably unnoticeable) slow down each request, but it will certainly be less effort on your part.

    Assuming you are using Apache, create an .htaccess file with a rewrite rule similar to the following (untested).

    RewriteEngine On
    RewriteRule \.html$ /injector.php
    

    This will cause every request for an html file to be passed to injector.php

    Inside this file, you can see the page that was originally requested using $_SERVER['REQUEST_URI']. Fetch this file from disk using a DOMDocument and locate the area you want to inject into using the built in methods (If you want to put a <script> in the <head> you probably only need getElementById). Inject your code, and spit out the modified document.

    FYI, it is perfectly allowed by the law to use cookies that are necessary for operation, this includes things like PHP session ids, and, a cookie to store any preferences related to cookie use. I repeat, it is fine to use a cookie to store the preference that a user does not want to use cookies.

    In your injector.php you can detect the presence of such preference cookies, and based on that decide not to inject your javascript if you so desire.

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

Sidebar

Related Questions

i have the follow code: searchResults.SearchResultCollection.Add( new SearchResult() { Header = HttpUtility.HtmlDecode( htmlDocument.DocumentNode .SelectSingleNode(initialXPath
Starting a new big C multiplatform project, what rules should one follow to avoid
I have a follow-up question to this one . I created a new form,
Can anyone confirm that after changing the Apple Push Certificate to follow the new
I want to new a StringArray as follow: class Test { public: QString* str[];
I am new to maven and I am trying to follow this example but
I am new in rails,and I create the first rails application (Blog) follow the
I am new to stackoverflow as a member, although I follow this a lot
I am new to VB. I read a book and follow its code Public
I am quite new with Linq to SQL and MVC but I follow the

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.