Learning how tow work with HTML a tag target options
There are a few options we have when we create a link regarding where the target will open up: _blank, _self, _ parent, _top and even custom names - by the end of this video you will know all that you need to know about how to work with the target options.
Video Transcript
00:00The next ones that we want to do is we really need another page for it,
00:04to make that happen we'e going to go into our application and what I'm going to do
00:11is first of all I'm going to go into my editor here and copy this page and paste it right into same spot
00:20and I'm going to rename it to be 'inner frame'
00:27and now that we have an inner frame, let's go into our editor, open it up
00:30and create a dummie application inside of our inner frame,
00:35In our inner frame I'm going to call this, the title will be 'inner frame'
00:40and I'm going to delete everything we have in here and instead of that put here an h1
00:44a nice big H1,
00:46and call it: Inner frame
00:51Once I've done that and I have my inner frame,
00:54Remember when we're talking about relative paths and full paths?
00:58it works exactly in the same way with iframes, in this case if I wanted to load up the inner frame,
01:03and the inner frame that HTML has in the exact same folder as my iframe
01:08all I need to do is just reference the name of the file here instead of the full domain path,
01:14so I could type here innerframe.html, save it
01:18now that I've done that I could go back into my browser and now I'm going to see that inside of my frame
01:23I'm going to have actually that inner frame element, alright?
01:28Now that I have my inner frame inside how about if we make it a little bit stand out,
01:32how about if we give it a background color ?
01:34It's not part of our training, we're going to do this in css,
01:37I'm going to show you how to do it in css and it's kind of going to be a side-note,
01:41don't worry if you don't memorize it at this stage, but you should be able to do it already,
01:45I'm going to type here a word style and right inside here I'm going to write background
01:52and I'm going to set a color which is going to be a hex color,
01:58the name stands for doesn't really matter,
02:00but what it means is that you have 3 colors, red, green and blue
02:05for the first two numbers you put inside is for red the next two are green, and then blue
02:13the numbers are kind of weird but the numbers basically start from zero and they and they end at 'f '
02:18so it's instead of 1,2,3,4,5,6,7,8,9 it's 0 through F
02:25so once you get to 9 then it turns to a,b,c,d,e,f
02:29and the idea behind it is to be able to have 2 letters represent a lot more variations
02:35so these 2 letters combine could create up to 255 variations,
02:41this is 255 variations, this is 255 variations and this is 255 variations,
02:48so we could very easily now create some sort of a color without a mega huge number,
02:56and this number would be some sort of shade of grey I believe, but actually we don't want to
03:02put this directly in our iframe, or maybe we do,
03:05I want to put inside of that internal frame, so in that inner frame I'm going to put that into that body, style
03:11and you could do a style to literally any element in HTML, alright
03:16So now that I put it inside of our inner frame and we're going to click on refresh,
03:19now we're going to see that we have a new color inside of our inner frame,
03:23Obviously that's just a peak into a css, we're not really learning css here, it's just a peek
03:29The next thing we want to do now that we have a frame that's internal to us and local to us,
03:34I want to update this frame to let's say be 02geek.com again,
03:39to do that from outside all I have to do is go back to my link that I built
03:44and in the link instead of setting my link to go to a target that's blank,
03:52I could actually say it: go to a specific frame,
03:56the way I do that, I first have to give a name to my frame, I'm going to give my frame a name,
04:02Let's call it: inner frame, now it has a name of inner frame, I could then paste that into the target itself
04:10Now, that we have a name to our frame and we have a target to our click,
04:14once we click on it what would happen?
04:17It would load into that inner frame area right into this iFrame,
04:21whatever we click on it's going to load in to that inner frame,
04:26so again, I'm going to go into a browser, we're going to click on refresh, and if I click inside again,
04:32you'll see that the site is loaded inside of this frame,
04:36So we saw how to load in to the top, well not really, we saw how to load in a new frame,
04:43but let's see what it means when we say load in to the top?
04:46Now when we say load in a file into the top, we could say for example if we go into our editor again
04:52But this time I'm going to go into the frame and I want to add a link inside of the frame
04:57'Inner frame link to blog' We're going to make a link to the blog,
05:10so again: href, we're going to do 'a' tags, surround but we want it to be a link,
05:16write the word: href, put the link itself. In our case it's going to be blog.everythingfla.com
05:23we're going to save that, now that we have that saved, all that's left for to go back into a browser
05:28and click on refresh to see what would happen?
05:31Let me ask you, just for a guess. What do you think would happen when we click on tha 'link to blog'?
05:35What would update?
05:37-the blog. -well, where would it load?
05:39-Would it load into the frame? or would it load into the whole area? or a new frame?
05:44-Into the frame. -bingo, exactly.
05:47so you definitely got it,
05:48It loads out blog, and it loads it right inside of our frame.
05:53Now if we wanted it to load all the way to the top and say like we wanted to load it onto everything we're in
05:59very easily, we already know how to load it into a blank window by using the underscore blank into the target
06:05but instead of that what we could do is one of two options,
06:08one is to set it all the way to the top frame, or the other one is to say to the parent,
06:13now, to self is the default. In this case if we go back into the code again, once we set our href
06:21for the clarity and we have our target, and in that target we could set it by default it's going to be self like you say
06:30but instead of that we could say we want it to go to the parent, and by saying that we want it to go to the parent
06:36it means we're trying to update the parent itself and not the inner frame itself,
06:39now again, if we go into our browser again and click on refresh and this time around we're going to click on it
06:45it should update our whole browser, does it make sense ?
06:49another option that we have inside of our code there
06:52I'm going to go right back into our editor,
06:56so this is a 'link to blog' and let's make it a little bit more interesting,
07:01how about we'll just write here, so our students will be able to remember this,
07:05it'll be 'type of links' and we're going to just put here the names of the types so...
07:11this is going to be 'parent'
07:14I'm going to create another couple of links, so we have one that's going to go to the parent,
07:18one that's going to go into self, which we met already,
07:24I'm going to type here a copy of 'self' maybe I'll put here a coma so it'll be easy to see that they're separated
07:31and again we'll do one more so we know self, we know parent the next one is top,
07:37Now in this case it won't make any difference to us because we have two iframes,
07:41but there are situations where there's like 3, 4 iframes one inside of each other
07:46usually that happens in kind of like hacky sites that try to take over your browser and not enabling you to go forward
07:52very common unfortunately, in those usually use a lot of 'top' and kind of like put inside.
07:59Trying to take over in control of your browser, we don't really do this stuff, but it's good to know how it works,
08:04so the 'top' basically forces all the way to the top itself, it's not only one parent
08:08so if it's an iframe in an iframe in an iframe it will still go all the way to the top of the browser,
08:13Alright, now we saw also how to work with the specific name, and we saw how to work with blank,
08:19so there we go we got all the different important ways of interacting with different frames,
08:23I'm just going to type here also, so you guys have it, and this one will be blank
08:34Just to recap, we said there's a few different ways of loading up a link,
08:39and we said it's really dependents if it's inside of an iframe or it's not inside of an iframe,
08:43and that's where the parent in the top where it would be important, the self it's a default,
08:47many times you really want to open up a new window so you'll use the blank option,
08:51and if you want to load something into a specific frame then you have to give it a name,
08:55once the frame has a name the you could give it a specific target,
08:59okay? Let's just save it, we'll see one last time, make sure it all works and everything makes sense,
09:11first of all, we click on parent, it will load up into a parent,
09:14if we click into a self it'll load inside of itself,
09:17if we click onto the top it will do exact same thing as a parent,
09:20because we don't have iframes one inside of each other,
09:24and if we ask for a blank it will open it up in a new tab
09:27if we go into 02geek.com from outside where we actually set to go into the frame itself
09:32it will load into the frame itself and there you go, now you know every single thing you need to know
09:36about the basics about how to load files and how to work with iframes
09:40and go ahead and start playing with it, we learnt a lot of stuff,
09:43so take 15 minutes break and start playing with it, how about create that sample
09:47where we have an iframe inside of an iframe inside of an iframe and see what happens
09:51-Thank you.
