Shareen Watson
Shareen Watson

Reputation: 13

Modal HTML window popup that is run within 3rd party site

I have a need to display our application widget within a third-party website (think things like GetSatisfaction, UserVoice and other feedback widgets that people use).

What is the safest and most reliable way to do this? I can think of some criteria and issues already:

  1. The code needs to be framework and language independent. Even though my app is ASP.NET, the 'launcher' will be run in any HTML page that belongs to our customers. So I suppose that limits me to HTML and Javascript only.
  2. The function needs to be very easy to call. So that implies a <script scr='mywebsite.com/widget.aspx' ...> as the sole thing to give to my customer.
  3. There is to be no use of CSS. Or rather, I can style things, but without a CSS file, as that could pull in styles that conflict with what my customer is running.
  4. There must be no use of libraries such as JQuery. I mention this because I can imagine problems if we pull in a JQuery version that differs from our customer's, thus ruining their site with our code.

Ideally, is there a well established piece of code I can use to get started?

Upvotes: 1

Views: 1520

Answers (1)

Matt
Matt

Reputation: 385

Probably the easiest way to isolate your widget from all of the customer's JS and CSS code is to embed it in an IFRAME.

If necessary, you can provide a script that will inject the IFRAME into the document. You can keep your variables isolated from the global namespace by encasing everything like so:

(function() {

    //inject iframe into document.

})();

Upvotes: 1

Related Questions