简体   繁体   English

通过ajax调用将html,js和css小部件加载到外部站点

[英]Load html, js and css widget into external site via ajax call

I have a web page that should fire an ajax request to load into a div a widget consisting of a html block, a css file and 2 js files (jquery lib and file that holds the widget logics). 我有一个网页,应该解雇一个Ajax请求加载到一个div由HTML块,一个CSS文件和2个js文件(jQuery的lib和文件保存小部件逻辑)的部件。

What is the best way to get the external code into the main site and what to do in order to not interfere with other .js libraries and .css classes that are loaded in the main site? 什么是使外部代码进入主站点的最佳方法,以及如何做才能不干扰主站点中加载的其他.js库和.css类?

Currently I am using iframes but because of several reasons I want to remove them. 目前,我正在使用iframe,但是由于多种原因,我想删除它们。

Thanks for your answers. 感谢您的回答。

The long and the short? 多头和空头? You can't access 3rd party content programmatically from your page. 您无法通过页面以编程方式访问第三者的内容。 You can create 'pages in pages'(iframes) so to speak. 可以这么说,您可以创建“页面中的页面”(iframe)。

Or you can make the 3rd party content part of your page using html tags like <script> and <style> . 或者,您可以使用<script><style>类的html标签将第三方内容作为页面的一部分。 This would mean, though, that the content would possibily interface with yours. 但是,这意味着内容可能与您的内容交互。

If you have access to the 3rd party server, you can use CORS. 如果您有权访问第三方服务器,则可以使用CORS。

But due to many cross-site-scripting security concerns, cross-site coding is prohibited 但是由于许多跨站点脚本安全问题,所以禁止跨站点编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM