Created
July 17, 2013 17:52
-
-
Save arielcr/6022819 to your computer and use it in GitHub Desktop.
The embed.js script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseQuery ( query ) { | |
var Params = new Object (); | |
if ( ! query ) return Params; | |
var Pairs = query.split(/[;&]/); | |
for ( var i = 0; i < Pairs.length; i++ ) { | |
var KeyVal = Pairs[i].split('='); | |
if ( ! KeyVal || KeyVal.length != 2 ) continue; | |
var key = unescape( KeyVal[0] ); | |
var val = unescape( KeyVal[1] ); | |
val = val.replace(/\+/g, ' '); | |
Params[key] = val; | |
} | |
return Params; | |
} | |
var myScript = document.getElementById('my-embed'); | |
var queryString = myScript.src.replace(/^[^\#]+\#?/,''); | |
var params = parseQuery( queryString ); | |
var my_url = encodeURIComponent(window.location.href); | |
document.getElementById('my-embed-content').innerHTML = '<iframe src="http://yourdomain.com/embed.php?acc='+params['acc']+'&url='+my_url+'" width="'+params['w']+'" height="'+params['h']+'" frameborder="0" scrolling="auto" ></iframe>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment