www.webdeveloper.com
Results 1 to 4 of 4

Thread: Losing variable in Javascript

  1. #1
    Join Date
    Oct 2009
    Posts
    20

    Losing variable in Javascript

    Hi

    I use a function : updateytplayerInfo that gives me the time to be played of a Utube film (it counts down every second)

    I want to close that window when the count down has reached 0
    I know that functions lose his value outside the function.
    PS the function is not self made!!

    function updateytplayerInfo() {

    updateHTML("SBvideotime02", getDuration()-getCurrentTime());

    }

    Resuming Time to be played : <span id="SBvideotime02"></span>


    Simon, Netherlands
    Last edited by nachtegaal9999; 11-10-2009 at 04:28 PM.

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    you can only close popups, but this is how it's done:


    Code:
    function updateytplayerInfo() {
     if(!getDuration()-getCurrentTime()){window.close();}
    updateHTML("SBvideotime02", getDuration()-getCurrentTime());
    
    }

  3. #3
    Join Date
    Oct 2009
    Posts
    20
    Hi,

    Thanks for your quick reply, i.ve tested the script but it doesn't work.
    I think that when youtube starts the value is 0 and closes the window
    directly.
    But no matter you gave me the solution to close the window
    I use instead for this the next scrpt

    function onytplayerStateChange(newState) {
    if (newState === 0) {window.close();}
    setytplayerState(newState);
    }

    Thanks a lot
    best regards
    Simon , Netherlands

  4. #4
    Join Date
    Dec 2008
    Posts
    488
    you can only close popups
    Just to extend that further, you can only close pop-ups using the document from which they are opened.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles