Skip to content

Instantly share code, notes, and snippets.

@hallvors
Created December 12, 2013 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hallvors/7928615 to your computer and use it in GitHub Desktop.
Save hallvors/7928615 to your computer and use it in GitHub Desktop.
Test case for SUMO issue 975037
<!DOCTYPE html>
<html>
<head><title>document.write and the back button</title></head>
<body>
<p>FAILED (not ran)</p>
<iframe src="./"></iframe>
<script>
// there is something odd with document.write() and IFRAME
// one immediately, inline
writeIframe('1st time - inline');
// one from onload handler
window.onload = function(){
writeIframe('2nd time(?) - onload');
}
// and one after onload
setTimeout(function(){
writeIframe('3rd time - timeout');
document.getElementsByTagName('p')[0].textContent += ' history.length: '+history.length
},1200);
function writeIframe(str){
var ifr = document.getElementsByTagName('iframe')[0];
ifr.contentDocument.open();
ifr.contentDocument.write('<html><p>document.write("'+str+'")</p></html>');
ifr.contentDocument.close();
}
document.getElementsByTagName('p')[0].textContent = 'How many times do you need to click the back button here?';
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment