javascript - How can I start a delayed sound on a page I'm about to navigate to? -


my onclick function start delayed sound never getting called, or is, no sound happens. depends on navigate in conjunction onclick, , navigate. understand sounds killed when navigate away. below code. func, little_ding(), arranges do_bike_bell() called 1.5 sec later.

there's 4 cases. cases a/b within home page, navigating same/different page. c/d similar, within non home page.

case works fine. case b calls little_ding(), do_bike_bell() never called. cases c&d never call little_ding(). w/ chrome. case b sort of works in firefox: after return home page, do_bike_bell() called , hear it- not intention.

// javascript function do_bike_bell() {     //prompt("hello do_bike_bell()");     audio_ld.play();     settimeout(kill_bike_bell,4000);} // kill later sure  function little_ding()  {   // prompt("hello little_ding()");     settimeout(do_bike_bell,1500); }  // html. home_page.html calls same/level 2 page: <a href="#id_in_same_file"   onclick="javascript:little_ding();">text</a> // case  <a href="poems/trinity.html" onclick="javascript:little_ding();">text</a> // case b  // level 2 page calls same/level 3 page: <a href="#id_in_same_file"   onclick="javascript:little_ding();">text</a> // case c <a href="lev3_page.html"     onclick="javascript:little_ding();">text</a> // case d 

// audio object created this, in main page's window.onload func():

audio_ld = document.createelement("audio"); audio_ld.src = "./sounds/bicycle-bell.mp3"; 

// level 3_page.html (didn't help):

<body onload="javascript:little_ding();"> 


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -