How to use .show() and .hide() with opener?
I have a page with few photos, when a photo is clicked, a div opens using the whole avaliable screen's space to show an album ... like the facebook's photo viewer. Now, I want to press the ESC key and back to the first page ...
PS: inside the div showAlbumD开发者_运维问答iv I call an Iframe, and by jquery.css property I chance the iframe's src property. Its because i have to passa an variable by get to the album viewer !
im using the following code in the album viewer:
jQuery(document).ready(function($) {
//closingDiv
$(document).keyup(function(e) {
if (e.keyCode == 27) {
$('#showAlbumDiv', window.opener).hide();
$('.allOfIt', window.opener).show();
$('#showAlbumDiv',window.opener).css('visibility','hidden');
} // esc
});
The opener has the divs allOfIt and showAlbumDiv .... the online sample is in http://videoarts.com.br/newSite/portifolio ...
only the album viewer: http://videoarts.com.br/newSite/album/40
Any help !?
thns !
window.opener
tries to operate on another window - the one that opened this window. By your comment, it sounds like you're opening a new div in the same window. If that's the case, then window.opener
is the wrong code. You want to operate in the same window and thus don't need to pass a context to the jQuery functions as they default to the current document.
If you do mean to operate on another window, then (as I asked in my comment), please describe how a new window actually gets opened. Clicking on a photo does not open a new window, it just displays additional content in the current window.
If you're using embedded iframes, then you may want window.parent
, not window.opener
to get the parent document.
精彩评论