Skip to content

Instantly share code, notes, and snippets.

@mrcljx
Created April 20, 2012 15:06
Show Gist options
  • Save mrcljx/2429445 to your computer and use it in GitHub Desktop.
Save mrcljx/2429445 to your computer and use it in GitHub Desktop.
Intelligent iFrame
<iframe id="theGameFrame" src="about:blank" width="784" height="1000"></iframe>
<script type="text/javascript">
(function () {
"use strict";
var hash, match,
location = document.location.href,
theFrame = document.getElementById('theGameFrame');
if (location.indexOf('#') >= 0) {
hash = location.slice(location.indexOf('#') + 1);
match = /spiel=([a-z0-9]+)/i.exec(hash);
if (match !== null) {
theFrame.src = "http://tatort-plus.tatort.de/game/" + match[1];
return true;
}
}
theFrame.src = "http://tatort-plus.tatort.de/game";
return false;
}());
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment