Difference between revisions of "Widget:High-Elf-Swordsman"
From Rivendom
| Line 19: | Line 19: | ||
var iframe = document.getElementById('monsterframe'); | var iframe = document.getElementById('monsterframe'); | ||
var innerDoc = iframe.contentDocument || iframe.contentWindow.document; | var innerDoc = iframe.contentDocument || iframe.contentWindow.document; | ||
| − | var statBlockContent = | + | var statBlockContent = innerDoc.getElementsByTagName('stat-block')[0]; |
| − | document.getElementById('mw-content-text').innerHTML += | + | document.getElementById('mw-content-text').innerHTML += statBlockContent; |
} | } | ||
document.getElementById('monsterframe').contentWindow.onload = grabStatBlock(); | document.getElementById('monsterframe').contentWindow.onload = grabStatBlock(); | ||
</script> | </script> | ||
Revision as of 01:24, 21 August 2015
<iframe id="monsterframe" src="" style="display:none;"></iframe> <script>
function getStatBlockContent(document){
var statBlockContent = document.getElementsByTagName('stat-block')[0];
if (statBlockContent === null || statBlockContent === undefined) {
var statBlockContent = document.getElementsByTagName('stat-block')[0];
if (statBlockContent === null || statBlockContent === undefined) {
alert("There is no StatBlock Content");
return null;
} else {
return statBlockContent;
}
return statBlockContent;
}
}
function grabStatBlock() {
var iframe = document.getElementById('monsterframe');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var statBlockContent = innerDoc.getElementsByTagName('stat-block')[0];
document.getElementById('mw-content-text').innerHTML += statBlockContent;
}
document.getElementById('monsterframe').contentWindow.onload = grabStatBlock();
</script>