• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 6. Using Dreamweaver: Advanced T... > Including the Open Browser Window be...

Including the Open Browser Window behavior

To include the Open Browser Window behavior in your code, follow these steps:

  1. Highlight the item you'd like to use as a trigger.

    The trigger should be an image or bit of text; you need to have a link on the page so the user can make the window open.

  2. If the Behaviors panel isn't open, you can access it by choosing Window⇨Behaviors.

  3. In the Behaviors panel, click the Add Behavior button (the plus sign at the top).

  4. From the pop‐up menu, choose Open Browser Window.

  5. Make changes in the Open Browser Window dialog box that opens. (See Figure 6-12 .)

    Figure 6-12: The Open Browser Window dialog box.

    1. Type the URL you would like to open in the URL to Display text box, or click the Browse button and browse to the file within your site that you'd like to open.

    2. Set the window width and height to customize the size. Just enter the numbers; the unit of measure is pixels. So, if you'd like your window to be 500 pixels wide and 400 pixels high, enter 500 in the width box and 400 in the height box.

      You can set the size to any size you'd like.

    3. Enable the check boxes of the attributes you'd like to select.

      Attributes further affect the features and appearance of the new browser window, such as whether scroll bars appear in the new window, whether the user can resize the window, and so on.

    4. Type a name in the Window Name text box.

      Give the new window a name that can be referred to by other JavaScripts you might want to implement.

      A benefit of using a window name is that you can prevent multiple new windows from opening by using the same name in other instances of the open browser window script within your site. If a visitor clicks an instance, a new window opens. When he clicks another instance that targets the same window, the new content replaces the old content.

      Another benefit of using this method of opening another browser window — you can control that window via JavaScript that calls that new window by the name you give it. A downside is that a few users don't allow JavaScript to run in their browsers. It is possible that they could miss out on your content.

  6. Click OK.

    Dreamweaver inserts code into the head section of your Web page that makes the behavior work. Dreamweaver also inserts some code at the location that you highlighted in Step 1. This code is there to trigger the behavior that is placed in the head.

If you want to reuse the code on multiple pages or if you'd like to keep your pages clean, you can cut and paste the JavaScript from the head of the document into an external JavaScript file by following these steps:

  1. Choose File⇨New from the Dreamweaver menu bar.

  2. In the New Document dialog box, choose Category⇨Basic⇨JavaScript.

  3. Click Create.

  4. Save the new file to your local Web site folder.

    If you don't have a folder called Scripts in the site folder, create one:

    1. Choose File⇨Save As from the Dreamweaver menu bar.

    2. Browse to the folder that holds your local Web site.

    3. Click New Folder.

    4. Name the Folder Scripts.

    5. Save the new JavaScript file with a Web‐legal name. (See Book II, Chapter 2 for information about Web‐legal names.)

  5. Look for code that looks like the following in the head section of your HTML document:

    <script language="JavaScript" type="text/JavaScript">
    <!‐‐
    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
    }
    //‐‐>
    </script>

  6. Cut all of the code that starts with function and ends with the second curly brace, like this:

    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
    }

    The curly brace is very important. If you don't have that curly brace, the code will be broken!

  7. Paste this code into the new JavaScript file.

    The remaining code looks like this:

    <script language="JavaScript" type="text/JavaScript">
    <!‐‐
    //‐‐>
    </script>

  8. Remove the comments and add a link to the JavaScript file:

    <script src="scripts/myscript.js" language="JavaScript" type="text/JavaScript"></script>
    
    					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint