打开窗口并在该窗口上运行功能 [英] open window and run function on that window

查看:95
本文介绍了打开窗口并在该窗口上运行功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打开一个新窗口,该窗口有一个对象列表,这些对象应根据上一个窗口中的选择进行过滤.我以为可以通过一个函数过滤列表,但是如何运行所说的函数呢?

I'd like to open a new window, this window has a list of objects, and these objects should be filtered based on a selection from the previous window. I figured I can filter the list through a function, but how do I run said function?

这就是我能做的:

var popup = window.open('pageURL');
    $(popup.document).ready(function() {
        // this is where function should be
        popup.alert('HelloWorld');
    });

但是如何将警报更改为功能?

But how do I change the alert to a function?

如果我在其他应用程序上具有功能,则function test() { alert('HelloWorld'}; 如何从第一个应用程序运行此功能?

If I have a function on my other app , function test() { alert('HelloWorld'}; How do I run this function from my first app?

popup.test();交换popup.alert('HelloWorld');无效.

推荐答案

您需要引用打开的窗口以在新窗口中调用函数,例如:

You need the reference to the window opened to call functions in the new window, like:

var oNewWindow = window.open("new.window.url", "mywindow");
oNewWindow.onload = function(){oNewWindow.window.newWindowFunction();};

这篇关于打开窗口并在该窗口上运行功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆