Last active
November 16, 2019 17:55
-
-
Save lebaz20/a82c0ff589780544733c55b6e7671437 to your computer and use it in GitHub Desktop.
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
var script = document.currentScript; | |
var token = script.getAttribute('data-token'); | |
var bgdColor = script.getAttribute('data-bgd-color'); | |
var textColor = script.getAttribute('data-text-color'); | |
console.log('location.href', location.href) | |
var iframe = document.createElement('iframe'); | |
iframe.frameBorder = "0"; | |
iframe.src = 'child.html?token=' + token + '&bgd-color=' + bgdColor + '&text-color=' + textColor; | |
document.body.appendChild(iframe); |
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
<html lang="en"> | |
<head></head> | |
<body> | |
<p>this is iframe</p> | |
<p>Token is <span id="title"></span></p> | |
<button id="send">to be colored</button> | |
<script> | |
var params = location.href.split('?')[1].split('&'); | |
var data = {}; | |
for (x in params) | |
{ | |
data[params[x].split('=')[0]] = params[x].split('=')[1]; | |
} | |
if (data['bgd-color']) { | |
document.getElementById('send').style['background-color']=data['bgd-color']; | |
} | |
if (data['text-color']) { | |
document.getElementById('send').style.color=data['text-color']; | |
} | |
if (data.token) { | |
document.getElementById('title').innerText=data.token + document.referrer || 'no domain'; | |
} | |
</script> | |
</body> | |
</html> |
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
<html lang="en"> | |
<head></head> | |
<body> | |
<script src="app.js" data-token="dummytoken" data-bgd-color="#000" data-text-color="yellow"></script> | |
<iframe frameborder src="child.html?token=dummytoken&somedata=5&bgd-color=#000&text-color=yellow" /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment