最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How close popup window on ESC keydown on javascript - Stack Overflow

programmeradmin5浏览0评论

My problem is like this: ESC-problem

But the difference is that, I do not have access to content of child window( I cant put script in that).

Is that possible that I handle esc keydown in parent window for child window.

My problem is like this: ESC-problem

But the difference is that, I do not have access to content of child window( I cant put script in that).

Is that possible that I handle esc keydown in parent window for child window.

Share edited May 23, 2017 at 12:16 CommunityBot 11 silver badge asked Aug 14, 2013 at 12:02 Masoud NazariMasoud Nazari 4962 gold badges7 silver badges17 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

This is all you need.

var myWindow = window.open();

myWindow.onkeydown = function(e){
    if(e.keyCode === 27){
        alert('esc key pressed');
    }
};

You can't, but you can use ajax to load specified content into a simulated window (a div or something styled like a window, that should not be hard to do), in your own page, where you can do anything you want.

This is also (in most cases anyway) a better way to load content than pop-ups.

发布评论

评论列表(0)

  1. 暂无评论