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

Chapter 4. Content > Viewing Someone Else’s External JavaScript or CSS

Viewing Someone Else’s External JavaScript or CSS

The best way to learn about DHTML and CSS (other than reading this book) is to look at other Web sites and dissect their code. Unfortunately, Web designers sometimes hide their code by placing it in external files that don’t show up when you attempt to view the source in the usual way.

Never fear—you can view the code if you’re willing to dig a bit.

To view hidden code:

Open the Web page for which you want to find the code (Figure 4.6).

Figure 4.6. The page with the external code you want to see. The absolute path is at the top.

View the source code.

Different browsers have different ways of providing access to the source code, but you’ll typically find a View Source or Source command in the View menu (Figures 4.7 and 4.8).

Figure 4.7. The View menu in Internet Explorer.

Figure 4.8. The View menu in Netscape.

In the source code, find the reference to the external code you want to view (Figure 4.9).

Figure 4.9. The source code for the Web page. Many of the links to external files use a relative path (meaning the URL is relative to the current page’s URL).

You may have to do some hunting, but the <script> (for JavaScript) or <link> (for CSS) tag will be in the head of the document.

Piece together the URL to the external content: <script> tags have a src attribute for the URL and <link> tags use href.

If the URL is an absolute path (begins with http://), use that exact URL in step 5.

If it is a relative path, start with the current URL (the one in the browser’s location/address bar), less the filename. For every ../ in the relative URL, remove an additional level from the end of the current page’s URL, and add the relative path to it. Then add the remainder of the page’s URL to the relative path without ../ (Figure 4.10).

Figure 4.10. A simple equation that finds the absolute URL for the external content.

Open the URL for the external content that you found in step 4 (Figure 4.11).

Figure 4.11. The external code’s URL typed in the browser’s location bar.

Again, different browsers have different methods, but the File menu typically contains an Open Location command. A shortcut is to type the URL in the browser’s address/location bar. Some browsers open the code directly in the browser window; others require you to download the code file first (Figure 4.12) and then open it in a program such as Notepad (Windows) or TextEdit (Mac) (Figure 4.13).

Figure 4.12. Some browsers require you to download the file rather than view it in your browser.

Figure 4.13. The external source code you seek.

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