SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    window.opener.$() not working in IE9

    The use of jQuery below does not work for IE9 but works beautifully for Firefox, Chrome & Safari. Before I rewrite it without jQuery, I was hoping to get some feedback on what I've done. Not certain about standards compliance, just know it works fine for all the browsers I'm testing except IE.

    The user provides an action from a popup window. The action references the opener window, removes a few elements from a hidden element and then immediately repopulates those elements with updated values based on that action.

    Code JavaScript:
     
    // does not appear work like this in IE9
    window.opener.$('div#hiddenShiftAbbrList').empty();
     
    for (var j = 0, jj = nShifts; j < jj; j++)
    {
         var newDiv = document.createElement("div");
         newDiv.setAttribute('id', j);
         // response[][] array is reference for value that new text node will take 
         newDiv.appendChild(document.createTextNode(response[0][j]));
         // does not appear to work like this in IE9
         window.opener.$('div#hiddenShiftAbbrList').append(newDiv);
    }

    If anyone has had success with a similar approach for IE, I'd appreciate the help. Thanks.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,678
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ryan77 View Post
    If anyone has had success with a similar approach for IE, I'd appreciate the help. Thanks.
    When the child is in control of making changes to the parent, there seems to be security-based problems there.

    So, there seems to better success when the child calls a function of the parent, and passes appropriate data to that function so that the parent is then in charge of making such changes.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I can buy that. Will explore that logic and post a response when I come up with something that works. Thanks, Paul.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it working for IE9! Will incorporate that IE security logic into my coding from now on. Thanks, Paul! Super satisfying. Here're the changes I made to my code:

    Code JavaScript:
    //---------------------------
     
    // js file associated with child (popup) window action
    window.opener.ryanLib.emptyHiddenShiftList();
    window.opener.ryanLib.repopulateShiftList(nShifts,response);
     
    //---------------------------
     
    // js file associated with parent window; functions called on by popup window;
    // little function library I created (non-object literal notation)
    var ryanLib = {};
     
    // 1) empty hidden shift list elements
    ryanLib.emptyHiddenShiftList = function()
    {
    	$('div#hiddenShiftAbbrList').empty();
    };
     
    // 2) repopulate with new values
    ryanLib.repopulateShiftList = function(nShifts, response)
    {
    	for (var j = 0, jj = nShifts; j < jj; j++)
    	{
    		var newDiv = document.createElement("div");
    		newDiv.setAttribute('id', j);
    		newDiv.appendChild(document.createTextNode(response[0][j]));
    		$('div#hiddenShiftAbbrList').append(newDiv);
    	}
    };
     
    //---------------------------

    Works like a charm. Thanks again.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •