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

  • Home
  • SEARCH
  • 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 608007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:25:06+00:00 2026-05-13T17:25:06+00:00

I need to be allow content from our site to be embeded in other

  • 0

I need to be allow content from our site to be embeded in other users web sites.
The conent will be chargeable so I need to keep it secure but one of the requirements is that the subscribing web site only needs to drop some javascript into their page.

It looks like the only way to secure our content is to check the url of the page hosting our javascript matches the subscribing site. Is there any other way to do this given that we don’t know the client browsers who will be hitting the subscribing sites?

Is the best way to do this to supply a javascript include file that populates a known page element when the page loads? I’m thinking of using jquery so the include file would first call in jquery (checking if it’s already loaded and using some sort of namespace protection), then on page load populate the given element.

I’d like to include a stylesheet as well if possible to style the element but I’m not sure if I can load this along with the javascript.

Does this sound like a reasonable approach? Is there anything else I should consider?

Thanks in advance,

Mike

  • 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-13T17:25:07+00:00Added an answer on May 13, 2026 at 5:25 pm

    It looks like the only way to secure our content is to check the url of the page hosting our javascript matches the subscribing site.

    Ah, but in client-side or server-side code?

    They both have their disadvantages. Doing it with server-side code is unreliable because some browsers won’t be passing a Referer header at all, and if you want to stop caches keeping a copy of the script, preventing the Referer-check from taking place, you have to serve with nocache or Vary: Referer headers, which would harm performance.

    On the other hand, with client-side checks in the script you return, you can’t be sure your environment you’re running in hasn’t been sabotaged. For example if your inclusion script tag was like:

    <script src="http://include.example.com/includescript?myid=123"></script>
    

    and your server-side script looked up 123 as being the ID for a customer using the domain customersite.foo, it might respond with the script:

    if (location.host.slice(-16)==='customersite.foo') {
        // main body of script
    } else {
        alert('Sorry, this site is not licensed to include content from example.com');
    }
    

    Which seems simple enough, except that the including site might have replaced String.prototype.slice with a function that always returned customersite.foo. Or various other functions used in the body of the script might be suspect.

    Including a <script> from another security context cuts both ways: the including-site has to trust the source-site not to do anything bad in their security context like steal end-user passwords or replace the page with a big goatse; but equally, the source-site’s code is only a guest in the including-site’s potentially-maliciously-customised security context. So a measure of trust must exist between the two parties wherever one site includes script from another; the domain-checking will never be a 100% foolproof security mechanism.

    I’d like to include a stylesheet as well if possible to style the element but I’m not sure if I can load this along with the javascript.

    You can certainly add stylesheet elements to the document’s head element, but you would need some strong namespacing to ensure it didn’t interfere with other page styles. You might prefer to use inline styles for simplicity and to avoid specificity-interference from the page’s main style sheet.

    It depends really whether you want your generated content to be part of the host page (in which case you might prefer to let the including site deal with what styles they wanted for it themselves), or whether you want it to stand alone, unaffected by context (in which case you would probably be better off putting your content in an <iframe> with its own styles).

    I’m thinking of using jquery so the include file would first call in jquery

    I would try to avoid pulling jQuery into the host page. Even with noconflict there are ways it can conflict with other scripts that are not expecting it to be present, especially complex scripts like other frameworks. Running two frameworks on the same page is a recipe for weird errors.

    (If you took the <iframe> route, on the other hand, you get your own scripting context to play with, so it wouldn’t be a problem there.)

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

Sidebar

Related Questions

I need to allow users to upload PDF documents that other users will read.
I am building a web application that will need to allow users to save
I need to allow users to select an assembly in much the same way
I have a need to allow my users to execute .NET code that they
I have an Excel 2007 ODBC connection defined and I need to allow users
I need to write some sql that will allow me to query all objects
I know that services like my.yahoo.com allow you to add content from RSS feeds
I need to allow a consultant to connect to SSIS on a SQL Server
I need to allow multiple Products to be present in a Cart. I do
I need to allow multiple downloading of small documents in Rails, preferably using Paperclip

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.