简体   繁体   English

弹出窗口中的.NET MVC 4网站javascript功能无法运行

[英].NET MVC 4 website javascript function in popup window wouldn't run

I am working on questionnaire that is being asked when user lands on the page, if he agrees to do it popup window (action is on different Controller) is opened (works fine) an when main window is closed it should signal to popup to start questionnaire. 我正在调查问卷,当用户登陆页面时被询问,如果他同意这样做,则弹出窗口(动作在不同的Controller上)被打开(工作正常),当主窗口关闭时,它应该提示弹出窗口开始问卷。 However following mechanism does not seem to trigger the startSurvey function. 但是,以下机制似乎并未触发startSurvey函数。

$('.askForFeedback a.yes').click(function() {
            window.survey = window.open("../Home/CustomerFeedback", "Customer Feedback", "width = 600px, height = 400px");
            window.onbeforeunload = function() {
                window.survey.startSurvey = function() {
                    $('.survey-questions').show();
                    $('.leave-window-open').hide();
                };
                window.survey.startSurvey();
            };
        });

Could it be because of different MVC controller or maybe because of onbeforeunload ? 可能是因为MVC控制器不同,还是因为onbeforeunload I must be missing something obvious here. 我一定会在这里遗漏一些明显的东西。

For those wondering this does work. 对于那些想知道这样做是否有效的人。

 $('.askForFeedback a.yes').click(function() {
      window.survey = window.open("Home/CustomerFeedback", "Customer Feedback", "width = 600px, height = 400px");
      window.onbeforeunload = function() {
          $(window.survey.document).find('.survey-questions').show();
          $(window.survey.document).find('.leave-window-open').hide();
      };
 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM