You are here: Re: CSS & Div Tag, Hyperlinked? « HTML « IT news, forums, messages
Re: CSS & Div Tag, Hyperlinked?

Posted by Ben C on 10/06/06 15:45

On 2006-10-06, Yogi_Bear_79 <nospam@spamsux.com> wrote:
>
> "Ben C" <spamspam@spam.eggs> wrote in message
> news:slrneic6b7.elb.spamspam@bowser.marioworld...
>> On 2006-10-06, Yogi_Bear_79 <nospam@spamsux.com> wrote:
>>>
>>> "Harlan Messinger" <hmessinger.removethis@comcast.net> wrote in message
>>> news:4olbu8Ff1nu8U1@individual.net...
>>>> Ben C wrote:
>>>>> On 2006-10-05, Yogi_Bear_79 <nospam@spamsux.com> wrote:
>>>>>> I created a floating window with the code below. I call it with <div
>>>>>> id="Uleft"></div>. It contains a table with text and one image. I
>>>>>> would
>>>>>> like to make the entire container clickable. When I click on it I want
>>>>>> the parent page to change to another page on my website. How?
>>>>>
>>>>> Put the whole lot inside an <a> element.
>>>>
>>>> A DIV element can't go inside an A element. Only inline elements
>>>> (excluding another A) can go inside an A.
>>>
>>> So is it not possible to do what I want?
>>
>> You can use JavaScript:
>>
>> <script>
>> function click()
>> {
>> location = "http://www.google.co.uk";
>> }
>>
>> function main()
>> {
>> var e = document.getElementById("Uleft");
>> e.addEventListener("click", click, false);
>> }
>>
>> onload = main;
>> </script>
>>
>> In your document somewhere should do the trick.
>
> Thanks! I guess I still need a little more help though. I tried the code in
> the BODY tag, the DIV tag, and even as a SSI, but nothing happens. any
> ideas?

I tried it and it did work for me. Are you using Firefox? If so you get
a "JavaScript Console" (Tools menu) that tells you the errors. Otherwise
you can put alerts in there to check which bits are being executed etc.

Putting the <script> in the head element might be the best place, to be
sure it's run before the document.onload event happens (which it's then
going to listen for). But I think anywhere _should_ be fine.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация