开发者

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

开发者 https://www.devze.com 2023-02-11 13:27 出处:网络
I have a need to display our application widget within a third-party website (think things like GetSatisfact开发者_JAVA技巧ion, UserVoice and other feedback widgets that people use).

I have a need to display our application widget within a third-party website (think things like GetSatisfact开发者_JAVA技巧ion, 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?


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.

})();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号