...

View Full Version : Can one hyperlink a DIV?



effpeetee
12-26-2007, 09:24 AM
Some time ago I had a program where I wanted to use the images and thumbs to use by clicking the thumbs and getting the main jpeg on screen which I then wanted to get back to the index page. I managed to make it work without linking each seperate image by linking the Div that they were in.
I cannot find the program now, but it worked well (to my surprise because I did not know why!) and had merely found it by trial and error.

Have you any idea how I did it?

Frank

Arbitrator
12-26-2007, 10:57 AM
Have you any idea how I did it?You can hyperlink a div element using non‐standard scripting. Below is an example of inline JavaScript.


<div onclick="window.location.href = 'http://www.ie7.com/';">HTML</div>

Another method would be to put an anchor element inside of the div element and size the anchor element such that its height and width are the same as the div element. Below is an example.


a { display: block; }



<div><a href="http://www.ie7.com/">HTML</a></div>

Depending upon your needs, the div element may be unnecessary in the last example since display: block makes the anchor element behave identically to the div element.

effpeetee
12-26-2007, 11:27 AM
Thank you for your help.
What I am trying to do is:
I use a thumbnail of an image to link to the main jpg and then link back to the original showing of the thumbnails. At present I am using html to present the main image. It works fine accept the as I use the same images in more than one list, it means different html page for each menu that I need to return to. I have nearly 100 html pages which I have repeated four times in order to use in three seperate menus. eg 101a, 101b, 101c. As each page is identical is seems rather silly. Being able to link from the image by linking to its DIV would mean that I could just show the image without an unnecessary html page to carry it, in order to use the pages link.

I hope that this is clear. Basically I need thumbnail, linked to main image linked back to thumbnails. Nothing else used. I did it once. Lost the original program and I am saddled with an 82 year old forgetary. (memory?):rolleyes:

http://www.exitfegs.co.uk/Picchoosea.html
http://www.exitfegs.co.uk/Picchoose.html

This is how I do it at present.

Frank

Majoracle
12-27-2007, 12:24 AM
So you basically want an image gallery. Try this if you like:

http://www.huddletogether.com/projects/lightbox2/

You'll have to make a few edits, so read over it very carefully. I use it, and it works like a charm. Your thumbnail links will look like this:

<a href="http://www.domain.com/images/image.jpg" rel="lightbox" title="Image description"><img src="http://www.domain.com/images/thumbnail.jpg" alt="alternative" /></a>

effpeetee
12-27-2007, 01:06 PM
Thanks for your input, but I already have this and other galleries. My previous post tells what I need and why I need it. It is not just to get a gallery, but to enable me to use the same hyperlinked images in more than one list.

http://www.exitfegs.co.uk/Picchoose.html

http://www.exitfegs.co.uk/Picchoosea.html
http://www.exitfegs.co.uk/Picchooseb.html
http://www.exitfegs.co.uk/Picchoosec.html

The last three use the same images as the first but have to return to different menus. This means each html has to be saved four times for the different links.

eg 1.html 1a.html 1b.html etc

I want to end that and just use the actual jpegs and fix the link to the DIV enclosing them.

Frank

Majoracle
12-28-2007, 12:37 AM
Oh I see. I'm sure others in the past have brought this up, but have you considered using a server-side language such as PHP with a database like MySQL? Provided you have access to such things. If not, that's a shame. With client-side scripting (HTML, CSS), there's not much you can do to simplify things unfortunately. :(

effpeetee
12-28-2007, 12:19 PM
Oh I see. I'm sure others in the past have brought this up, but have you considered using a server-side language such as PHP with a database like MySQL? Provided you have access to such things. If not, that's a shame. With client-side scripting (HTML, CSS), there's not much you can do to simplify things unfortunately. :(
Thanks friend, but unfortunately my knowlegde of php is nil and at 82 years old I find html and css quite enough to cope with. Having said that it occured to me that my program "Sources", in my signature, does exactly what I need to do. I am now in the process of modifying it to serve again.

Here it is. http://www.exitfegs.co.uk/ExpMenu.html

Regards,

Frank



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum