Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.