Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rel attribute and Javascirpt 1

Status
Not open for further replies.

ice78991

Programmer
Nov 20, 2006
216
I've been lookig at the following code and I have found the following rel attribute. Can someone explain how this attribute is working? The html file comes with a file named lightbox.js and I'm wondering if this may be the javascript document being linked to?

<td><a href="images/M2.jpg" rel="lightbox[portfolio]" title="Title">
<div align="center"><img src="images/smM2.jpg" width="80" height="80" border="0"></div>
</a></td>
 
The Lightbox script itself will be linked to via a <script> tag within the HTML. When the page loads, the Lightbox script runs and it will find any link with the rel="lightbox" attribute and attach a custom behaviour to that link.

Lightbox is a neat image gallery type tool that will cause images tagged with rel="lightbox" to open in a virtual 'layer' above the main page, greying the page out in the background.

The additional [portfolio] bit is telling lightbox that this particular image is part of a set called [portfolio]. This enables some extra navigtional features when viewing the images.

The benefit of working this way is that even without Javascript, the user will be able to see the images. The links will simply act normally and open the image in the current browser window. But with Javascript enabled, the click is intercepted by the script and the magic happens.

<honk>*:O)</honk>

Earl & Thompson Marketing - Marketing Agency Services in Gloucestershire
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top