Untitled
4 years ago in Plain Text
<html>
<script>
function bindEvent(element, eventName, eventHandler) {
if (element.addEventListener){
element.addEventListener(eventName, eventHandler, false);
} else if (element.attachEvent) {
element.attachEvent('on' + eventName, eventHandler);
}
}
bindEvent(window, 'message', function (e) {
if(e.data.mode=="iframe"){
var iframe = document.createElement("iframe");
iframe.src = e.data.url;
iframe.onload = function(e){
window.location = this.contentWindow.name;
}
document.body.appendChild(iframe);
}
});
window.addEventListener('message', function(e) {
} , false);
</script>
</html>