var questionnaireUrl = "http://demovik.kitten.fr-wd.com/support_ticket_system/questionnaire/trunk/www/index.html"; var idBlockToInsert = 'loadpage'; var authUrl = 'questionnaire_auth/auth.php' var callbacks = new Object(); function getJSONP(url,cb) { var i; do i = 'c' + Math.floor(Math.random() * 99999); while(callbacks[i]); callbacks[i] = function(obj) { cb(obj); delete callbacks[i]; }; var script = document.createElement('script'); script.src = url + (url.indexOf('?') >= 0?'&':'?') + 'callback=callbacks.' + i; script.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(script); } function onSuccess(response) { var frame = document.createElement('IFRAME'); frame.id = 'quest-loader'; frame.scrolling = 'auto'; frame.src = questionnaireUrl + '?key=' + response.session; frame.setAttribute('frameborder', 0); setTimeout(function () {appendFrame(frame);}, 500); } function appendFrame(frame) { document.getElementById(idBlockToInsert).appendChild(frame); } getJSONP(authUrl, onSuccess);