Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to check popup is open or not in javascript

var popup = window.open('','mypopup');
// now popup is know again
popup.document.getElementById("player").someFunction(); 


var page_id = getURLParameter('pageID'),
    popup_opened = readCookie('music_popup'),
    popup_url = '?pageID=music_popup',
    popup_name = 'musicPopup',
    popup_wh = 'height=720,width=980',
    musicPopup;

// open the popup if there isn't the popup_opened cookie 
if(!popup_opened){
    musicPopup = window.open( popup_url, popup_name, popup_wh);
};

$('.c_music').click(function(event) {
    event.preventDefault();
    //when the user click on a .c_music link check if popup is defined (I'm in the opener page)
    if(musicPopup !== undefined) {
        musicPopup.focus();
        musicPopup.document.getElementById("start").click();
        return false;
    } else {
        // I'm not in the opener page, so a call the popup again
        var musicPopup = window.open('', popup_name, popup_wh) ;
        // if popup doesn't exist a blank one would be opened
        if(musicPopup.location == 'about:blank' ){
            // load the desired content in the popup
            musicPopup.location = popup_url;
            return false;
        }
        // the popup still exist, so start the music again
        musicPopup.document.getElementById("start").click();
    };
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: jest called times 
Javascript :: browser.find_element_by_ <a 
Javascript :: blob to pdf javascript 
Javascript :: react google map api 
Javascript :: string to query string javascript 
Javascript :: open dev server 
Javascript :: javascript access pushed element 
Javascript :: react google places auto complete example 
Javascript :: convert date format mm/dd/yyyy to yyyymmdd in javascript 
Javascript :: update node two versions mac 
Javascript :: componentdidmount react hooks 
Javascript :: can we add two functions onclick event 
Javascript :: add new array at the back of react state 
Javascript :: es6 range 
Javascript :: jest mock jwt-decode 
Javascript :: iterate array 
Javascript :: call by value and call by reference in javascript 
Javascript :: nodejs parallel async calls -1 
Javascript :: angular online editor 
Javascript :: faker js uuid example 
Javascript :: javascript object properties 
Javascript :: ejemplo async await javascript 
Javascript :: javascript select letter in string 
Javascript :: array.length 
Javascript :: js round floar 
Javascript :: javascript eval() function 
Javascript :: reduce method in javascript 
Javascript :: node http 
Javascript :: how to upload picture on canvas in react 
Javascript :: Angular patchValue dynamically 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =