how to change parent window when modal Window is open

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
uday M
Forum Newbie
Posts: 5
Joined: Sat Jan 24, 2009 8:00 am

how to change parent window when modal Window is open

Post by uday M »

hi,
i want to change parent window while modal Window opening or opened

my php code is

Code: Select all

 
<li>
  <div class='newsPopUpModal'>
<a href='#'  onmouseover=JT_show('".base_url().index_page()."interest/show_news_detail."/".$detail_val['file_name'].") onmouseout='removetip();' class='jTip' id='".$detail_val['tip_id']."' onclick=openMyModal('".$detail_val['title_link']."','".base_url().index_page()."interest/".$interest_id.$arr_detail_val[0]['file_name']."');>".$detail_val['title']."
</a>
</div>
</li>";
 
while click on title above will open modal window ,now i want to change parent window.

javascript code

Code: Select all

 
 var modalWindow = {
   parent:"body",
   windowId:null,
   content:null,
   width:null,
   height:null,
   close:function(pagesource)
   {   window.location = pagesource;
      $(".modal-window").remove();
      $(".modal-overlay").remove();
 
   },
   open:function(pagesource)
   {           //alert(pagesource);
      var modal = "";
      modal += "<div class=\"modal-overlay\"></div>";
        modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:- 0px; margin-left:- 0px;\">";
      modal += this.content;
      modal += "</div>";
       $(this.parent).append(modal);
//        window.opener.location.href = pagesource;
 
      $(".modal-window").append("<a class=\"close-window\"></a>");
      $(".close-window").click(function(){modalWindow.close(pagesource);});
      $(".modal-overlay").click(function(){modalWindow.close();});
   }
};
 
 
 var openMyModal = function(source,pagesource)
 {
     modalWindow.windowId = "myModal";
     modalWindow.width = 900;
     modalWindow.height = 550;
     modalWindow.content = "<iframe width='900' height='550' frameborder='0' scrolling='yes' allowtransparency='true' src='" + source + "'></iframe>";
     modalWindow.open(pagesource);
 };
 
pls help
nyoka
Forum Commoner
Posts: 45
Joined: Thu Apr 09, 2009 12:53 pm

Re: how to change parent window when modal Window is open

Post by nyoka »

Code: Select all

var openMyModal = function(source,pagesource)
  {
      modalWindow.windowId = "myModal";
      modalWindow.width = 900;
      modalWindow.height = 550;
      modalWindow.content = "<iframe width='900' height='550' frameborder='0' scrolling='yes' allowtransparency='true' src='" + source + "'></iframe>";
      modalWindow.open(pagesource);
      location.href='the_page_to_load_in_the_parent_window.html';
  };
uday M
Forum Newbie
Posts: 5
Joined: Sat Jan 24, 2009 8:00 am

Re: how to change parent window when modal Window is open

Post by uday M »

nyoka wrote:

Code: Select all

var openMyModal = function(source,pagesource)
  {
      modalWindow.windowId = "myModal";
      modalWindow.width = 900;
      modalWindow.height = 550;
      modalWindow.content = "<iframe width='900' height='550' frameborder='0' scrolling='yes' allowtransparency='true' src='" + source + "'></iframe>";
      modalWindow.open(pagesource);
      location.href='the_page_to_load_in_the_parent_window.html';
  };

location.href='the_page_to_load_in_the_parent_window.html';
it's change location but close modal window, i want to display modal window also
Post Reply