Home >> FAQs/Tutorials >> XHTML Tutorials and Tips >> Index

XHTML Tutorial - Creating A Link to Open a Document in a New Window

By: FYIcenter.com

(Continued from previous topic...)

How To Create A Link to Open a Document in a New Window?

Normally, if a hyper link is linked to a XHTML document, the browser will display the linked document in the same window as the current document. But if you want to the browser to display the linked document in a new window, you can add the target="_blank" attribute in the "a" tag of the hyper link.

Note that, the "target" attribute in valid only in the "Frameset" version of XHTML 1.0, so you have to use the xhtml1-frameset.dtd in your XHTML document.

Here is good tutorial example about opening the linked document in a new window:

<?xml version="1.0" ?>
<!DOCTYPE html
 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head>
  <title>Open Documents in New Windows</title>
 </head>
 <body>
  <p>Click the hyper link to open the 
  <a href="http://dev.fyicenter.com/faq/"
   target="_blank">FAQ Index Page</a> in a new window.</p>
 </body>
</html>

If you save the above document as new_window.html, and view it with Internet Explorer, you will see a hyper link. If you click it, the linked document will opened in a new window:
            New Window

  1. What Are Hyper Links?
  2. What Is an Anchor "a" Tag/Element?
  3. How To Define a Hyper Link?
  4. How To Define a Bookmark?
  5. What Is a URL?
  6. What Is the Structure of a URL?
  7. What Happens If Protocol or Port Number Is Missing in a URL?
  8. What Happens If a URL Starts with Path or File name?
  9. What Is a Relative Path Name?
  10. What Happens If File Name is Missing in a URL?
  11. How To Build Hyper Link Indexes within the Same Document?
  12. What Happens If a Hyper Link Points to an Image?
  13. What Happens If a Hyper Link Points to a Music File?
  14. What Happens If a Hyper Link Points to a PDF File?
  15. What Happens If a Hyper Link Points to a ZIP File?
  16. How To Create A Link to Open a Document in a New Window?


Selected Developer Jobs:

More...