How do hosting services like UserVoice embed their content on other websites?

How do hosting services like UserVoice embed their content on other websites?

I see that this includes the JavaScript file from the service provider on your own page, however, I am interested in the building blocks for creating such a service.

For example, they use a library like jQuery, mooTools or prototypejs, and how do they avoid namespace conflicts?

It was also wondered if there were any books, articles, blog posts that affected this particular use of JavaScript (not looking for shared JavaScript resources).

Regards and thanks in advance,

Elliot

+1
source share
4 answers
+3

, , , "Javascript Widget" (UserVoice ).

Javascript Widgets, .

+2

:

  • , script , onload , ( , , ).
  • HTML- . HTML-, , script , innerHTML , DOM, .
  • script , .
  • JS ; , , .
+2

EDT: , // script , script :

JS ( )

   var script = document.createElement('script');
   script.type = 'text/javascript';
   script.src = 'your/remote/scripts/path.js';
   document.getElementsByTagName('body')[0].appendChild(script);

//$.getScript('/remote/scripts/path.js'); jquery, , jQuery

script ,

var body = document.getElementsByTagName('body') [0]; var aDiv = document.createElement('script'); /* div */ body.appendChild(Adiv); // $(''). appendTo ('body'); jQuery

For a deeper understanding of JavaScript, you can, for example, read Javascript: The Good Parts or The Ultimate Javascript Guide .

+2
source

Source: https://habr.com/ru/post/1718107/


All Articles