Question

Uniform Resource Locators (URLs)
Each web page on the Internet needs some sort of unique name so it can be identified. A page can be accessed by a Uniform Resource Locator (URL). URLs can be used to identify HTML files, PHP files, image files, plain text files, and many other file types. Here is an example URL:





Using the "target" Attribute to Launch a New Browser Window
When a user clicks on an external link from your website, they will normally leave your web site as the browser follows that external link. However, you may want them to see the information on the new website without leaving your site. This way, once they are done with the new site, they can easily move back to the content on your page. To do this, you need a way to send them to an external link in a new browser window and keep your site open in the current browser window.

You can create a new browser window or tab by putting a target attribute inside the anchor tag:The target value is the name of the browser window where you want the new site to appear. If there is no target attribute, the external site will appear in the current browser window, replacing your site. However, you can specify a target to open the new site in a new window.

The target value always starts with an underscore (_), followed by a name. Any links going to a named target will appear in the same browser window. Consider the example below, where two links have a "_cow" target and three links have a "_pig" target:The "target" attribute works on internal anchor links too! Even when staying within your own site, you may want to launch some special content such as a product description or picture in a new browser window.
You can force a brand new browser window to open on every click by using the target name "_blank". This will open a new unnamed window each click, no matter how many times a link with a "_blank" target name is clicked. This approach may be a better option if you want each page to appear in a new window.

Experiment with the sample external hyperlink below. The target is initially "_blank", so each time you click on the link in the output panel, your web browser should launch a new window or tab.Now, change the target to some other value that you define and refresh the output panel. Each time you click on that new link, it will direct your browser to the same new tab or window instead of creating a new window on each click.

1. What is a URL? Describe and diagram the different parts of a common URL.
2. Demonstrate the difference between the href attributes of an internal and an external link.
3. What is a trailing slash used for in a URL? When would you use the trailing slash and when would you not?
4. What does the target attribute do in an anchor element?



Answers

There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!

Related Questions