- HTML Атрибут target
- Синтаксис
- Значения
- Значение по умолчанию
- Применяется к тегам
- Отличия HTML 4.01 от HTML 5
- Примеры использования:
- Атрибут target (Элемент )
- Пример HTML:
- Атрибут target (Элемент )
- Пример HTML:
- Target to a page inside an iframe
- 2 Answers 2
- Targeting Links in HTML IFrames and Frames
- The Four Target Keywords
- How to Name Your Frames
- Setting a Default Target
HTML Атрибут target
Атрибут target (от англ. «target» — «цель, мишень») указывает место (фрейм или окно браузера) в которое должен быть загружен, указанный ресурс.
Для элемента определяет имя фрейма, в котором будут открываться все ссылки.
Действие target в качестве атрибута элемента распространяется на все ссылки документа, кроме ссылок в которых это действие переопределяется собственными атрибутами target .
Для элемента определяет указывает место (фрейм или окно браузера) в которое должен быть загружен ответ сервера (результат отправки данных формы).
Синтаксис
Значения
_blank Загружает страницу в новую вкладку браузера. _self Загружает страницу в текущую вкладку. _parent Загружает страницу во фрейм-родитель; если фреймов нет, то это значение работает как _self . _top Отменяет все фреймы и загружает страницу в полном окне браузера; если фреймов нет, то это значение работает как _self .
Значение по умолчанию
Применяется к тегам
Отличия HTML 4.01 от HTML 5
В HTML 4.01 атрибут считался устаревшим и не рекомендован к использованию, в HTML 5 он полностью поддерживается.
Примеры использования:
Атрибут target (Элемент )
Пример HTML:
Открыть пример в фрейме
Атрибут target (Элемент )
Пример HTML:
Target to a page inside an iframe
I will try to explain again: I have 3 images in my index.html that when clicked i’d like to point respectively to ourmission.html, ourvalues.html and ourvision.html. But this 3 pages are inside an iframe located in the page ourcompany.html as you can see below:
How do i to point them directly, so the page ourcompany.html will load with the specific iframe opened.
If I use the target=»iframe» I can point to the iframe but it will open its default page. But what I need to do is open directly the other pages inside the iframe instead of its default. Each item in page A will link directly to one of the iframe pages in page B.
so dont target it to its default page, target it to the other page. This is what I understand. YOu have pageA.html , pageB.html and pageC.html . Right now you have pageA.html with an iframe which has target=»pageB.html» but you want to see pageC.html . So what you need to do is target =»pageC.html» and that should show you that page.
2 Answers 2
This might be a possible solution for you, if I have understood you correctly. I am assuming you dont have a server set up with the website.
In your index.html, your image links need to be modified to this:
Notice the ?link=someValue after the ourcompany.html link. This is a GET request but you will use it to pass data between pages.
Now in your ourcompany.html page you need to get the value you sent after the ?link= . So you need to add some Javascript. This is the function you need to add to ourcompany.html:
function getValue() < // First, we load the URL into a variable var url = window.location.href; // Next, split the url by the ? var qparts = url.split("?"); // Check that there is a querystring, return "" if not if (qparts.length == 0) < return ""; >// Then find the querystring, everything after the ? var query = qparts[1]; // Initialize the value with "" as default var value = ""; var parts = query.split(" .html";//set the src >
Targeting Links in HTML IFrames and Frames
Jennifer Kyrnin is a professional web developer who assists others in learning web design, HTML, CSS, and XML.
The iframe tag is used to display a web page inside a web page. When you create a document to be inside an iframe, any links in that frame will automatically open in that same frame. But with the attribute on the link (the element or elements), you can specify where the links will open.
The first step is to give your iframe a unique name with the name attribute. Then, it’s a matter of pointing your links at that frame using the ID as the value of the target attribute:
If you add a target to an ID that doesn’t exist in the current browser session, the link will open in a new browser window, with that name. After the first time, any links that point to that named target will open in the same new window.
If you don’t want to name every window or every frame with an ID, you can still target some specific windows without needing a named window or frame. These are called the standard targets.
The Four Target Keywords
There are four target keywords that don’t require a named frame. These keywords allow you to open links in specific areas of the web browser window that might not have an ID associated with them. These are the targets that web browsers recognize:
This is the default target for any anchor tag. If you don’t set the target attribute or you use this target, the link will open in the same window or frame that the link is in.
Iframes are embedded inside web pages. You can embed an iframe in a page that is inside another iframe on another web page. When you set the target attribute to _parent, the link will open in the web page that is holding the iframe.
In most situations with iframes, this target will open links in the same way that the _parent target does. But if there is an iframe inside an iframe, the _top target opens links in the highest-level window in the series, removing all the iframes.
The most commonly used target, this opens the link in an entirely new window, similar to a popup.
How to Name Your Frames
When you build a web page with iframes, it’s a good idea to give each one a specific name. This helps you remember what they are for and allows you to send links to those specific frames. For example:
Setting a Default Target
You can also set a default target on your web pages using the element. Set the target attribute to the name of the iframe you want all links to open in. You can also set default targets for one of the four target keywords.