Create window popup with custom content instead of url?

て烟熏妆下的殇ゞ 提交于 2019-12-07 19:06:28

问题


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());
});

For example:

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 code http://jsfiddle.net/6cpup/11/


回答1:


EDIT:

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);

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



来源:https://stackoverflow.com/questions/20420462/create-window-popup-with-custom-content-instead-of-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!