本文介绍了使用自定义内容(而不是网址)创建窗口弹出式窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何一个让我想出实现窗口弹出窗口并访问父窗口的弹出窗口中的 js 变量。

Any one let me give an idea of implementing the window popup and accessing the js variable of parent window to popup window with custom content.

<div id="modeltext" style="display:none">
    <p id="linker" ></p>
    <script type="text/javascript">
        var news = "http://google.com";
        jQuery(document).ready(function() {
        jQuery('#linker').html("<a href="+news+">"+news+"</a>");
        });
    </script>
    This is for testing according to the concept.

</div>
<a href="#" id="testing" >Open a popup window</a>

JS:

jQuery('#testing').click(function() {

  var w = window.open($('', "", "width=600, height=400, scrollbars=yes"));
        alert(news);


        var $w = $(w.document.body);

        $w.html($('#modelText').html());
});

例如:

有一套集段和简单的html形式。如果有人点击父项的链接,例如(在新窗口中打开)。而不是url,我想加载自定义内容,也不能访问js变量值到弹出窗口。不确定任何建议是伟大的。我试图提供的js小提琴,但弹出窗口不工作。
是否有一种方法来显示自定义内容到弹出而不是url,并使用js变量从主窗口到弹出窗口?(如何获取窗口弹出窗口加载在父窗口)。
小提琴不工作但是这里是代码

Let consider i have set of set of paragraph and simple html form. If some one click the link from the parent like (Open in New Window). Instead of url, i want to load the custom content and also i can't able to access the js variable value to the popup window. Not sure any suggestion would be great. I try to provide the js fiddle but the popup is not working.Is there is a way to show the custom content to the popup instead of url and using the js variable from main window to the popup window ?(How to get the window popup load in the parent window).Fiddle not working But here is the codehttp://jsfiddle.net/6cpup/11/

推荐答案

编辑:

这是因为您错误地打开了窗口,请查看

I think it was caused because you incorrectly opened the window, check out this jsFiddle

 var w = window.open('', "", "width=600, height=400, scrollbars=yes");
    //alert(ICJX_JXPath);

 var html = $("#modeltext").html();

 $(w.document.body).html(html);

对于带有自定义HTML的弹出窗口,请查看此答案

For the popup with custom HTML, check out this answer Open window in JavaScript with HTML inserted

这篇关于使用自定义内容(而不是网址)创建窗口弹出式窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 16:01