- SockJS-node is running on 192.168.0.21:8081
- Sending a message from the main page works everywere
- Sending a message from the iframe or popup does not works in IE8
Created
May 1, 2014 17:12
-
-
Save yannickcr/5472d08a75e43174e249 to your computer and use it in GitHub Desktop.
Testing SockJS iframe-htmlfile transport under IE8
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="X-UA-Compatible" content="IE=8" /> | |
<meta charset="UTF-8" /> | |
<script src="lib/sockjs.js"></script> | |
</head> | |
<body> | |
<button id="sendmessage">Send from main page</button> | |
<button id="popup">Open popup</button> | |
<iframe src="/iframe.html"></iframe> | |
<script> | |
// SockJS-node running on 192.168.0.21:8081 | |
var sock = new SockJS('http://192.168.0.21:8081/echo', null, { | |
protocols_whitelist: [ | |
'iframe-htmlfile' // The transoport we want to test | |
] | |
}); | |
// Informative messages | |
sock.onopen = function() { | |
console.log('open'); | |
}; | |
sock.onmessage = function(e) { | |
console.log('message', e.data); | |
}; | |
sock.onclose = function() { | |
console.log('close'); | |
}; | |
// Open the iframe in a popup | |
document.querySelector('#popup').attachEvent('onclick', function() { | |
window.open('/iframe.html', 'WindowName', 'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes'); | |
}, true); | |
// Send a message from the main page | |
document.querySelector('#sendmessage').attachEvent('onclick', function() { | |
sock.send("Here's some text that the server is urgently awaiting!"); | |
}, true); | |
</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
<!doctype html> | |
<html> | |
<head> | |
<meta http-equiv="X-UA-Compatible" content="IE=8" /> | |
<meta charset="UTF-8" /> | |
<title></title> | |
</head> | |
<body> | |
<button id="sendmessage">Send from popup/iframe</button> | |
<script> | |
document.querySelector('#sendmessage').attachEvent('onclick', function() { | |
// Use opener (popup) or parent (iframe) SockJS instance to send a message | |
(window.opener || window.parent).sock.send("Here's some text that the server is urgently awaiting!"); | |
}, true); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment