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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:05:49+00:00 2026-05-16T11:05:49+00:00

I am working on implementing a JavaScript web bug that will be inserted into

  • 0

I am working on implementing a JavaScript web bug that will be inserted into our client’s web pages. One of the features our clients would like, is a way to pass pieces of the HTML on their web pages to our server through the web bug. We are using JSONP and the server that is hosting the JavaScript web bug is different than the server hosting the we page. The basic idea is this:

var element = document.getElementById(id);
var html = element.innerHTML;
//Encodes HTML into GET request www.example.com/script?html=encodedhtml
var url = getSrcUrl(html); 
document.write(unescape("%3Cscript src='" + url + "' type='text/javascript'%3E%3C/script%3E"));

The security problem is that anyone could make a get request to our server with arbitrary HTML that isn’t from the web page that is hosting the web bug. Is there anyway to make this secure?

I know we could check HTTP headers for the referrer, but this can easily be forged. I saw some ideas where the server passed a unique token that had to be returned in the GET request, but it seems like this could be forged too.

My hunch is that what we’re trying to do can’t be done securely, but I wanted to throw this out to the community to see if there’s something clever that can be done. Otherwise, I’m going to have to build a screen scraper that downloads the pages directly from our clients and extracts the relevant HTML for their page.

Thanks for any and all help!

EDIT

To be clear, our client’s web pages are public-facing without security. In other words, any Internet user could visit the page and execute the JavaScript bug that submits the HTML fragment.

EDIT 2

An acceptable answer is “this is impossible”! If that is the case, and you give a good explanation of why, I will choose it as the accepted answer.

EDIT 3

What we are building is a kind of Google Analytics system for our clients. We are trying to track visits to unique “items” by each visitor and then automatically collecting information about that item via the HTML fragment. We will then insert information about the item on other pages by injecting the HTML fragment that we collected from the original item. We are trying to do all this without requiring our clients to install anything on their severs and by just including out JavaScript web bug in their HTML.

  • 1 1 Answer
  • 2 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-16T11:05:50+00:00Added an answer on May 16, 2026 at 11:05 am

    If you want to ensure something wasn’t tampered with, it cannot go through the client unencrypted.

    The only ways to do this securely are to:

    • As you suggest, retrieve the appropriate page server-side

    or

    • Encrypt/sign the HTML before is goes to the client using a key unknown to them, so that the client cannot modify it
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on implementing a fulltext search engine for one of our sites,
I'm working on implementing javascript functionality in my rails 3 app. Now that rjs
I am currently working on a application that will be implementing user customizable widgets
I've been working on implementing a pretty complex system in JavaScript that needs to
I've have been working on implementing the InfoBox code for one of my web
working on a website that will sell one item each day that will run
I'm working on implementing a way to allow HTML in a field that I
Possible Duplicates: Javascript toSource() method not working Implementing Mozilla’s toSource() method in Internet Explorer.
I'm currently working on implementing the Distributed Annotation System-standard for our project openSNP.org, however,
As the complexity of the web projects that I am working on increases, 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.