< script type = 'text/javascript' > var ExtendVar='ExtendVar'; < / script > < script type = 'text/javascript' src = 'http://MySite.ru/js/script.js' >< / script >
< script type = 'text/javascript' > var ExtendVar='ExtendVar'; < / script > < script type = 'text/javascript' src = 'http://MySite.ru/js/script.js' >< / script >
- new MyClass ( ExtendVar ) ;
- function MyClass ( ExtendVar ) {
- this . ExtendVar = ExtendVar ;
- if ( this . ExtendVar ) {
- document. write ( "<a class = 'iframe fancy' href = 'http: //MySite.ru/" + this . ExtendVar + "' title = 'MySite.ru /" + this . ExtendVar + "' target = '_ blank' > <img src = 'http: //MySite.ru/img/dezign/MyButton.png' style = 'border: 0 none; position: relative;' alt = 'MySite.ru' /> </a> " ) ; // Insert your button
- // Check if jQuery is used on this site
- if ( typeof ( jQuery ) == 'undefined' ) { // If not, then connect
- var JQ = document. createElement ( 'script' ) ;
- Jq. src = 'http://MySite.ru/js/jquery.js' ;
- Jq. type = 'text / javascript' ;
- document. getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( JQ ) ;
- }
- waitJQ ( ) ; // Waiting for jQuery initialization and initialization
- } ;
- function waitJQ ( ) {
- if ( typeof ( jQuery ) == 'undefined' ) {
- window. setTimeout ( waitJQ , 100 ) ; // Recursion every 100 milliseconds until jQuery loads
- }
- else {
- // After successful determination of jQuery, we check whether the plugin we need is used on this site (in this case, fancybox)
- if ( typeof ( jQuery. fn . fancybox ) == 'undefined' ) { // If not, then connect
- jQuery ( "head" ) . append ( "<script type = 'text / javascript' src = 'http: //MySite.ru/js/fancybox.js'> </ script> <link rel =' stylesheet 'href =' http: // MySite. com / css / fancybox.css' type = 'text / css' media =' screen '/> " ) ;
- }
- waitFB ( ) ; // Waiting for the fancybox plugin to load and initialize
- }
- }
- function waitFB ( ) {
- if ( typeof ( jQuery. fn . fancybox ) == 'undefined' ) {
- window. setTimeout ( waitFB , 100 ) ; // Recursion every 100 milliseconds until fancybox is loaded
- }
- else {
- jQuery ( 'a.fancy' ) . fancybox ( { frameHeight : 190 , frameWidth : }} ) ; // Actually initialize the effect
- }
- }
- }
Source: https://habr.com/ru/post/58969/