Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dreamweaver behaviors

Explorer ,
Jun 18, 2018 Jun 18, 2018

Hello,

Is it possible to have more than one behavior initiate at the same time?  Actually, what I am trying to do is have a behavior such as puff happen just before connecting to a link.  Can sound happen along with another behavior?  I'm making a simple game and when the incorrect choice (photo) is chosen, I want to swap a photo with a "Try Again" image and have a sound (preferably one I can record myself) happen onClick (I am doing every behavior onClick).

Any ideas from you extraordinary minds?

Thanks in advance,

Robert

1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2018 Jun 18, 2018

As far as the sound part of your question, take a look at this JSFIDDLE.  As long as the user is using a recent browser, this will work for that part.

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 19, 2018 Jun 19, 2018

Thank you for getting back to me.

I know how to add audio to a site, but I have a specific question

concerning having audio render when I want to connect to another page by

link. My linking happens so fast (immediate)that I don't know how to

delay it long enough to have sound before...have the sound render before it

links.

But Mahalo for your comment.

Robert

On Tue, Jun 19, 2018 at 12:14 AM, WolfShade <forums_noreply@adobe.com>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2018 Jun 19, 2018

Are you using jQuery? 

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

<audio controls id="aH">
  <source src="http://www.w3schools.com/html/horse.ogg" type="audio/ogg">
  <source src="http://www.w3schools.com/html/horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

<a href="anotherpage.html" class="soundBefore">CLICK</a>

{load jquery before closing HTML tag}

<script>

     $('.soundBefore').click(function(e){

          e.preventDefault();

          $('#aH').play();

          setTimeout(function(){

               window.location.href = $(this).attr('href');

               },3000);// 3 seconds

               }

          );

</script>

Untested, but it should work.  Set the timeout to however long the audio is.

HTH,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 19, 2018 Jun 19, 2018

I really appreciate your help.

I'm not sure where to define the duration of the timeout. About 4 seconds

is about rights, Where do I place the timeout attribute?

On Tue, Jun 19, 2018 at 11:22 PM, WolfShade <forums_noreply@adobe.com>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2018 Jun 19, 2018
  1.           setTimeout(function(){ 
  2.                window.location.href = $(this).attr('href'); 
  3.                },3000);// 3 seconds \

setTimeout('function',3000) is 3000 milliseconds, or 3 seconds.  Set this to 4000 for four seconds.

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 19, 2018 Jun 19, 2018

I want to say it again, I really appreciate your help.

I'm not so slick with javascript. I live in Japan and have no access to

English speaking teachers. And as much as I DO get from youTube, it sends

me down many roads I get lost on.

This is how I wrote it (I used my own mp3 and linked to my html page.

onClick it immediately went to my htmlpage...no sound.














Your browser does not support the audio element.

CLICK

{load jquery before closing HTML tag}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 19, 2018 Jun 19, 2018

I also tried it exactly the way your wrote it:














Your browser does not support the audio element.

CLICK

{load jquery before closing HTML tag}

$('.soundBefore').click(function(e){
e.preventDefault();
$('#aH').play();
setTimeout(function(){
window.location.href = $(this).attr('href');
},3000);// 5seconds
}
);





Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2018 Jun 19, 2018

Are you loading jQuery?  I see where I left instruction to load jQuery before the script tag, but I don't actually see jQuery being loaded.

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2018 Jun 19, 2018

Also, I did an Inspect Element, and the anchor has no class value.

<a class="" href="https://forums.adobe.com/index.html">CLICK </a>

HTH,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2018 Jun 19, 2018

Copy/paste the following code into a new HTML document and test it.

<!DOCTYPE html>
<html>
<head><title>Audio Test</title></head>
<body>
    <audio controls id="aH"> 
      <source src="http://www.w3schools.com/html/horse.ogg" type="audio/ogg"> 
      <source src="http://www.w3schools.com/html/horse.mp3" type="audio/mpeg"> 
    Your browser does not support the audio element. 
    </audio> 
    <a href="anotherpage.html" class="soundBefore">CLICK</a> 
<script
src="https://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous"></script>
    <script> 
         $('.soundBefore').click(function(e){ 
              e.preventDefault(); 
              $('#aH').play(); 
              setTimeout(function(){ 
                   window.location.href = $(this).attr('href'); 
                   },3000);// 3 seconds 
                   } 
              ); 
    </script>
</body>
</html>

Nevermind.. it's not working for me, either.. hang on..

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 19, 2018 Jun 19, 2018

Sorry, it didn't work for me. I'm going to go to w3 site and learn this

stuff. Thanks for your help

On Wed, Jun 20, 2018 at 12:37 AM, WolfShade <forums_noreply@adobe.com>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2018 Jun 19, 2018
LATEST

I recommend MDN.  W3 is getting better, from what I hear, but they have/had a LOUSY rep for years.

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines