Create window popup with custom content instead of url?

16,151

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

Share:
16,151
Vignesh Pichamani
Author by

Vignesh Pichamani

சொல்லுதல் யார்க்கும் எளிய அரியவாம் சொல்லிய வண்ணம் செயல் - திருக்குறள்:664 Preaching is the easiest thing; to put it in practice is difficult.

Updated on June 14, 2022

Comments

  • Vignesh Pichamani
    Vignesh Pichamani almost 2 years

    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/