java后台返回javascript脚本,直接调用父窗口中的js方法

时间:2019-09-18
本文章向大家介绍java后台返回javascript脚本,直接调用父窗口中的js方法,主要包括java后台返回javascript脚本,直接调用父窗口中的js方法使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
java中的代码(输出Java本,调用方法);主要功能是,根据状态提示信息,然后获取页面上的信息,最后更加条件跳转页面。
@RequestMapping("/")
public void test(HttpServletResponse response){
	out = response.getWriter();
	out.println("<script>parent.frameCallback(\'" + JSON.toJSONString(tipResult) + "\')</script>");
	out.flush();
	out.close();
}
parent.frameCallback();parent表示父窗口的意思。
点击按钮页面的js中的方法
function frameCallback(msg) {
    msg = eval('(' + msg + ')');
    if (!msg.success) {
        layer.close(currTc);
        layer.open({
            type: 0,
            offset: '100px',
            title: '提示',
            content: msg.error
        });
    } else {
//        var insureForm = $('#insureForm');
//        insureForm.removeAttr('target');
//        $('#check').val(2);
//        insureForm.submit();
        //弹出投保确认页面
        var orderNo = msg.businessNo;
        // window.location.href="policyConfirm.htm?orderNo="+orderNo
        currTc = layer.open({
            title: false,
            type: 2,
            closeBtn: 0,
            offset: ['0px', '0px'],
            area: ['100%', '100%'],
            content: jsbasepath + 'wx/product/policyConfirm.htm?orderNo=' + orderNo,
            success: function (layero) {
                //layer.alert("成功添加!")
                $(layero).addClass("scroll-wrapper");//苹果 iframe 滚动条失效解决方式
            }
        });
    }
}

  

原文地址:https://www.cnblogs.com/lazyli/p/11541512.html