Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
So I am going to open and close my parenthesis after defining the function, open up a curly brace and I will like to hit Enter twice and close the curly brace. Now the reason I would like to do that is because all the code in the curly braces is going to be executed when the function is called and if you don't have a closing curly brace, its bad syntax and your function won't work. So a lot of times people will code forever in a day and they will forget that last closing curly brace and their function won't work. So I will go back up in line between that and I am just going to type in return and then a space and then the word true. So what this function is doing is just one thing, it's returning a value of true. When you select an item and you go up to the Behaviors panel and you click the Plus symbol, Dreamweaver is going to say hey, can this item on the page accept this behavior? This behavior is going to return true and say yes I can. You could add some conditional logic in this if you actually wanted to restrict to certain types of objects. So we will save this file and we will move on to our next function.
So we will be down to our next line and we will type in function then a space behaviorFunction. Now you have to stick with this naming convention, don't start changing the names of these functions because when you apply behavior, Dreamweaver is going to call these functions and look for their value and if it doesn't find those function, your behavior won't work. So again I will do an open and close parenthesis, open up a curly brace, I will hit Enter twice, I will close the curly brace. Now inside my new function skeleton, I am going to type in Return and then a space and then setActiveStyleSheet.
Now if that looks familiar, it should. That is the name of the function that we pasted at the top of the page, so if I scroll up to the very top of our code, you can see we have a function defined here called setActiveStyleSheet. So our behavior function, what that's doing is when Dreamweaver calls it and says okay where is the code for this behavior? It says go find the function setActiveStyleSheet. That's the code you need to bring in to the page that the behavior is being applied to.
Okay, so save that, and we have finished the first part of this. We have established our desired function. We are allowing any elements to trigger the behavior and we are telling Dreamweaver which function to add to the page that the behavior is being applied to. So our next step is to go ahead and begin creating the user interface, which will allow users to control our behavior.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.