var part_host = document.location.host; (function() { // Localize jQuery variable var jQuery; /******** Load jQuery if not present *********/ if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') { var script_tag = document.createElement('script'); script_tag.setAttribute("type","text/javascript"); //"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" script_tag.setAttribute("src", "http://fepem-espaces.staging.symane.com/js/jquery-1.4.2.min.js" ); if (script_tag.readyState) { script_tag.onreadystatechange = function () { // For old versions of IE if (this.readyState == 'complete' || this.readyState == 'loaded') { scriptLoadHandler(); } }; } else { // Other browsers script_tag.onload = scriptLoadHandler; } // Try to find the head, otherwise default to the documentElement (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); } else { // The jQuery version on the window is the one we want to use jQuery = window.jQuery; main(); } /******** Called once jQuery has loaded ******/ function scriptLoadHandler() { // Restore $ and window.jQuery to their previous values and store the // new jQuery in our local jQuery variable jQuery = window.jQuery.noConflict(true); // Call our main function main(); } /******** Our main function ********/ function main() { jQuery(document).ready(function($) { //console.log($.fn.jquery); /******* Load CSS *******/ var css_link = $("", { rel: "stylesheet", type: "text/css", href: "http://fepem-espaces.staging.symane.com/css/fepem-widget.css" }); css_link.appendTo('head'); /******* Load HTML *******/ var jsonp_url = "http://fepem-espaces.staging.symane.com/widget_jsonp.php?callback=?&f=1&h="+part_host; $.getJSON(jsonp_url, function(data) { //console.log($('#fepem-widget-container').attr('image')); $('#fepem-widget-container .widget-content').html(data.html); }); }); } })(); // We call our anonymous function immediately