PDA

View Full Version : Trying to understand <a href> concept


xs2abhishek1237
07-20-2009, 05:28 PM
Hi all,

I am struggling to understand the <a href> concept. By definition (W3schools) "a is used to create a link to another document, by using the href attribute". However when I look at the source for web sites like www.youtube.com or any other video hosting web-site I see that their video content is linked by href="..." . But if you click on that thumbnail the video starts it's playback on the same page without refreshing the whole page which is probably because it just stays in that <div> tag. But if I click the <a href> from the source it opens the video with the whole page formatted accordingly.
So, my question is how is this all done.

Thanks & Regards,
Abhishek

matthewm27
07-21-2009, 01:36 PM
It is done with Javascript. What it most likely does is links to an anchor (<a href="#">The number symbol is an anchor</a>), and than use the "onclick" attribute (<a href="#" onclick="dothis();">Make Javascript "dothis()" function run</a>) and put the Javascript in that!

Hope this helps, Matthew!

Vege
07-22-2009, 10:25 AM
Basically only way to change addressbar content without refresh and with javascript is using the anchor part which can be fetched with JS.
That trick is mostly used because address with anchor tag can be bookmarked.

So it's not used as anchor anymore but for keeping JS variables during reloads.

matthewm27
07-22-2009, 11:12 AM
Oh, well I still do Javascript with anchors and onclick using Ajax.

Vege
07-22-2009, 02:36 PM
So it's not used as anchor anymore but for keeping JS variables during reloads.
It ofcos can be used as anchor. This was a stupid sentence, i just men't to say some people invent new ways to use some tags.