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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:17:31+00:00 2026-05-10T14:17:31+00:00

While cross-site scripting is generally regarded as negative, I’ve run into several situations where

  • 0

While cross-site scripting is generally regarded as negative, I’ve run into several situations where it’s necessary.

I was recently working within the confines of a very limiting content management system. I needed to include database code within the page, but the hosting server didn’t have anything usable available. I set up a couple bare-bones scripts on my own server, originally thinking that I could use AJAX to import the contents of my scripts directly into the template of the CMS (thus retaining dynamic images, menu items, CSS, etc.). I was wrong.

Due to the limitations of XMLHttpRequest objects, it’s not possible to grab content from a different domain. So I thought iFrame – even though I’m not a fan of frames, I thought that I could create a frame that matched the width and height of the content so that it would appear native. Again, I was blocked by cross-site scripting ‘protections.’ While I could indeed load a remote file into the iFrame, I couldn’t execute JavaScript to modify its size on either the host page or inside the loaded page.

In this particular scenario, I wasn’t able to point a subdomain to my server. I also couldn’t create a script on the CMS server that could proxy content from my server, so my last thought was to use a remote JavaScript.

A remote JavaScript works. It breaks when the user has JavaScript disabled, which is a downside; but it works. The ‘problem’ I was having with using a remote JavaScript was that I had to use the JS function document.write() to output any content. Any output that isn’t JS causes script errors. In addition to using document.write() for every line, you also have to ensure that the content is escaped – or else you end up with more script errors.

My solution was as follows:

My script received a GET parameter (‘page’) and then looked for the file ({$page}.php), and read the contents into a variable. However, I had to use awkward buffering techniques in order to actually execute the included scripts (for things like database interaction) then strip the final content of all line break characters (\n) followed by escaping all required characters. The end result is that my original script (which outputs JavaScript) accesses seemingly ‘standard’ scripts on my server and converts their standard output to JavaScript for displaying within the CMS template.

While this solution works, it seems like there may be a better way to accomplish the same thing. What is the best way to make cross-site scripting work specifically for the purpose of including content from a completely different domain?

  • 1 1 Answer
  • 3 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. 2026-05-10T14:17:32+00:00Added an answer on May 10, 2026 at 2:17 pm

    You’ve got three choices:

    1. Create a server side proxy script.
    2. Create a remote script to read in remote dynamic HTML. Use a library like jQuery to make this easier. You can use the load function to inject HTML where needed. EDIT What I originally meant for example # 2 was utilizing JSONP, which requires the server side script to recognize the ‘callback=?’ param.

    3. Use a client side Flash proxy and setup a crossdomain.xml file on your server’s web root.

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

Sidebar

Ask A Question

Stats

  • Questions 259k
  • Answers 259k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer EDIT: I edited the old answer out as the changing… May 13, 2026 at 11:16 am
  • Editorial Team
    Editorial Team added an answer Ive been reading this great book on isometrics. They show… May 13, 2026 at 11:16 am
  • Editorial Team
    Editorial Team added an answer var a= []; for (i=0; i<20; i++){ a[i]= ['q'+i, i];… May 13, 2026 at 11:16 am

Related Questions

While cross-site scripting is generally regarded as negative, I've run into several situations where
Django comes with CSRF protection middleware , which generates a unique per-session token for
I am trying to create a website where I host my data on google
I have a mostly desktop programming background. In my spare time I dabble in
I'm evaluating the Microsoft Anti-Cross Site Scripting Library (AntiXSS V3) I have to say

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.