Click here to get back home

div as link not working in explorer

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
div as link not working in explorer pistacchio 09-07-2007
Get Chitika Premium
Posted by Benjamin Niemann on September 7, 2007, 1:17 pm
Please log in for more thread options


Hello,

pistacchio wrote:

> the site i'm working on ( http://www.gdp-portfolio.net/as/ ) is html
> 4.1 strict valid. needless to say, it has some incompatibility problem
> with explorer (testing with IE 6.0).
>
> The menu works great with firefox going from one page to the other.
> the code is:
>
> <a href = "#"><button><div id = "Bmenu2" onClick = "document.location
> = 'index.php?p=Chi'" onMouseOut = "javascript: menu.nascondi(2);"></
> div></button></a>
>
> and it doesn't work in IE. i've altro tried:
> - "onClick" in <button>
> - setting the href in <a>
>
> but no solution seems to work. any help?

Why use ONCLICK to fake a link at all? The only case I could think of, is
that the destination absolutely requires for some reason JavaScript and
should not be reachable by user-agents without JS. Even in that case HREF
should not be empty, but point to a document explaining this restriction.
So, if you really need JavaScript triggered by ONCLICK, put this and the
other attributes of the DIV into the A start-tag.
And what should be the purpose of the BUTTON element? Is the link contained
in a FORM? Although it is valid, BUTTONs outside of a FORM do not make
sense.

Surprisingly the code is actually valid. BUTTON allows (like INS or DEL)
to 'smuggle' block elements into places where only inline is allowed. In
contrast to INS/DEL I could not find any reference that it is not
conforming to use that trick...


HTH

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/

Posted by pistacchio on September 7, 2007, 1:30 pm
Please log in for more thread options


> Hello,
>
>
>
> pistacchio wrote:
> > the site i'm working on (http://www.gdp-portfolio.net/as/) is html
> > 4.1 strict valid. needless to say, it has some incompatibility problem
> > with explorer (testing with IE 6.0).
>
> > The menu works great with firefox going from one page to the other.
> > the code is:
>
> > <a href = "#"><button><div id = "Bmenu2" onClick = "document.location
> > = 'index.php?p=Chi'" onMouseOut = "javascript: menu.nascondi(2);"></
> > div></button></a>
>
> > and it doesn't work in IE. i've altro tried:
> > - "onClick" in <button>
> > - setting the href in <a>
>
> > but no solution seems to work. any help?
>
> Why use ONCLICK to fake a link at all? The only case I could think of, is
> that the destination absolutely requires for some reason JavaScript and
> should not be reachable by user-agents without JS. Even in that case HREF
> should not be empty, but point to a document explaining this restriction.
> So, if you really need JavaScript triggered by ONCLICK, put this and the
> other attributes of the DIV into the A start-tag.
> And what should be the purpose of the BUTTON element? Is the link contained
> in a FORM? Although it is valid, BUTTONs outside of a FORM do not make
> sense.
>
> Surprisingly the code is actually valid. BUTTON allows (like INS or DEL)
> to 'smuggle' block elements into places where only inline is allowed. In
> contrast to INS/DEL I could not find any reference that it is not
> conforming to use that trick...
>
> HTH
>
> --
> Benjamin Niemann
> Email: pink at odahoda dot de
> WWW:http://pink.odahoda.de/

it is not in a for and there's actually no need to use a javascript
code. now, i got rid of the button tag and the javascript and i
inserted the href in <a>.
you can check the page here:
http://www.gdp-portfolio.net/as/

it still doesn't work in IE.

here you check the validator:

http://validator.w3.org/check?uri=http%3A%2F%2Fwww.gdp-portfolio.net%2Fas%2Findex.php&charset=%28detect+automatically%29&doctype=Inline&group=0

(not valid)


Posted by Jonathan N. Little on September 7, 2007, 2:47 pm
Please log in for more thread options


pistacchio wrote:
>> Hello,
>>
>>
>>
>> pistacchio wrote:
>>> the site i'm working on (http://www.gdp-portfolio.net/as/) is html
>>> 4.1 strict valid. needless to say, it has some incompatibility problem
>>> with explorer (testing with IE 6.0).
>>> The menu works great with firefox going from one page to the other.
>>> the code is:
>>> <a href = "#"><button><div id = "Bmenu2" onClick = "document.location
>>> = 'index.php?p=Chi'" onMouseOut = "javascript: menu.nascondi(2);"></
>>> div></button></a>
>>> and it doesn't work in IE. i've altro tried:
>>> - "onClick" in <button>
>>> - setting the href in <a>
>>> but no solution seems to work. any help?
>> Why use ONCLICK to fake a link at all? The only case I could think of, is
>> that the destination absolutely requires for some reason JavaScript and
>> should not be reachable by user-agents without JS. Even in that case HREF
>> should not be empty, but point to a document explaining this restriction.
>> So, if you really need JavaScript triggered by ONCLICK, put this and the
>> other attributes of the DIV into the A start-tag.
>> And what should be the purpose of the BUTTON element? Is the link contained
>> in a FORM? Although it is valid, BUTTONs outside of a FORM do not make
>> sense.
>>
>> Surprisingly the code is actually valid. BUTTON allows (like INS or DEL)
>> to 'smuggle' block elements into places where only inline is allowed. In
>> contrast to INS/DEL I could not find any reference that it is not
>> conforming to use that trick...
>>
>> HTH
>>
>> --
>> Benjamin Niemann
>> Email: pink at odahoda dot de
>> WWW:http://pink.odahoda.de/
>
> it is not in a for and there's actually no need to use a javascript
> code. now, i got rid of the button tag and the javascript and i
> inserted the href in <a>.
> you can check the page here:
> http://www.gdp-portfolio.net/as/
>
> it still doesn't work in IE.
>
> here you check the validator:
>
>
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.gdp-portfolio.net%2Fas%2Findex.php&charset=%28detect+automatically%29&doctype=Inline&group=0

Cannot have a block element 'DIV' within an inline element 'A'. Anyway
why bother? Just put the JavaScript to change document's location (yes
using the 'onclick' attribute is JavaScript) and use the A's href as
links are supposed to work. If you want the hover effect then then style
the A elements as block and swap the background on hovers

A#menu1 { display: block; background-image(url(button1-off.jpg)... }
A#menu1:hover { background-image(url(button1-on.jpg) }
...

of course you need to style your new "blocks" to be the size your want
as if they where DIVs...


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Posted by André Gillibert on September 7, 2007, 2:43 pm
Please log in for more thread options


pistacchio wrote:

> the site i'm working on ( http://www.gdp-portfolio.net/as/ ) is html
> 4.1 strict valid.

I knew that valid was not synonymous of conforming, and conforming wasn't
synonymous of good.
The extent is just much larger than I thought.

> needless to say, it has some incompatibility problem
> with explorer (testing with IE 6.0).
>

God bless IE 6.0. It did the right thing: Not accepting to make this
"thing" work.

I won't focus on the accessibility issues.
Personally, I use Opera, and couldn't *understand* what it was supposed to
do, until I read the source code! I admit my JavaScripts were disabled, as
usual when I surf on the Web. That didn't help. Anyway, even with
JavaScripts on, it didn't work with Opera.

okay, now on topic:

The problem with your code is that you provide THREE click zones (a Bmenu
division, the anchor and the image map), at the exact same physical
location.

Now, when you click on it, IE and Opera interpret the click as a click on
the image map or maybe on the anchor, while FF interprets it as a click on
the Bmenu division.


> The menu works great with firefox going from one page to the other.

Browsers aren't good at testing the correctness of a site. The W3C
validator is powerful, but cannot fight again ingenious perversions like
<a ...><button><!--block-level element with *absolute* CSS positionning
--></button></a>.
That's not the first time I see that, and I think I can write a document
type definition to avoid this type of perversion.

Temptative solution (Keeping your original idea):

Image map:

                        <map name = "mapMenu">
                         <!-- optional area elements for backward compatibility -->
                                <area href = "index.php?p=Home" onMouseOver = "menu.mostra(1);" alt =
"Home" coords = "171,157,232,188">
                                <area href = "index.php?p=Chi" onMouseOver = "menu.mostra(2);" alt =
"Chi siamo" coords = "233,154,318,188">
                                <area href = "index.php?p=Aree" onMouseOver = "menu.mostra(3);" alt =
"Aree di Consulenza" coords = "319,151,472,188">
                                <area href = "index.php?p=Contatti" onMouseOver = "menu.mostra(4);"
alt = "Contatti" coords = "473,150,549,188">
                                <area href = "index.php?p=Recruitment" onMouseOver = "menu.mostra(5);"
alt = "Recruitment" coords = "550,150,650,188">
                                <area href = "index.php?p=Collaborazioni" onMouseOver =
"menu.mostra(6);" alt = "Collaborazioni" coords = "651,154,774,188">
                                <ul>
                                <li><a href = "index.php?p=Home" onMouseOver = "menu.mostra(1);"
coords = "171,157,232,188">Home</a>
                                <li><a href = "index.php?p=Chi" onMouseOver = "menu.mostra(2);" coords
= "233,154,318,188">Chi siamo</a>
                                <li><a href = "index.php?p=Aree" onMouseOver = "menu.mostra(3);"
coords = "319,151,472,188">Aree di Consulenza</a>
                                <li><a href = "index.php?p=Contatti" onMouseOver = "menu.mostra(4);"
coords = "473,150,549,188">Contatti</a>
                                <li><a href = "index.php?p=Recruitment" onMouseOver =
"menu.mostra(5);" coords = "550,150,650,188">Recruitment</a>
                                <li><a href = "index.php?p=Collaborazioni" onMouseOver =
"menu.mostra(6);" coords = "651,154,774,188">Collaborazioni</a>
                                </ul>
                        </map>


Bmenu elements (replace the unnamed div with this ul):

                <ul>
                        <li>
<a id=Bmenu1 href = "index.php?p=Home" onMouseOut =
"menu.nascondi(1);">
<img src="img/Bmenu1.gif" alt=Home>
</a>
<li>
<a id=Bmenu2 href = "index.php?p=Chi" onMouseOut =
"menu.nascondi(2);">
<img src="img/Bmenu2.gif" alt="Chi Siamo">
</a>
<li>
<a id=Bmenu3 href = "index.php?p=Aree" onMouseOut =
"menu.nascondi(3);">
<img src="img/Bmenu3.gif" alt="Aree di Consulenza">
</a>
<li>
<a id=Bmenu4 href = "index.php?p=Contatti" onMouseOut =
"menu.nascondi(4);">
<img src="img/Bmenu4.gif" alt=Contatti>
</a>
<li>
<a id=Bmenu5 href = "index.php?p=Recruitment" onMouseOut =
"menu.nascondi(5);">
<img src="img/Bmenu5.gif" alt=Recruitment>
</a>
<li>
<a id=Bmenu6 href = "index.php?p=Collaborazioni" onMouseOut =
"menu.nascondi(6);">
<img src="img/Bmenu6.gif" alt=Collaborazioni>
</a>
</ul>

Remove background images in CSS.


> but no solution seems to work. any help?
> thanks in advance - gu

Mine is a first step, but far from being ok.



--

Posted by André Gillibert on September 7, 2007, 3:06 pm
Please log in for more thread options


I wrote:

> Temptative solution (Keeping your original idea):

Sorry, my mind was corrupted by the site design. Even if my solution is
much better than the original, it's still non-sense.

Now, I'm going to cleanse my mind.

An image map: ok, this is not complete non-sense.

A style change when an item is hovered: Use CSS :hover pseudo-class to
change the background image.
This doesn't agree with the image map, I think (it's possible to do, but
cr*ppy).

So:
Forget about the image map.
Cut your picture in several images:
One for the top.
One for each "button".

Use an IMG tag for the top image.
Use an unordered list for other images. These images would be divisions
with a background image set with CSS and containing an good old anchor.
Use CSS to display them horizontally.
Use :hover to change the background image.

If CSS supports is partial, the list may be displayed differently, and yet
:hover would work or not, but that doesn't matter.
If CSS is disabled, it would still be ok.
If CSS and images are disabled, it should be ok.
If images are disabled but not CSS, it would not work too bad either.

--

Similar ThreadsPosted
URL link using Button not working in IE June 8, 2005, 2:43 pm
Problem with Anchor link now working properly in IE! February 1, 2005, 12:33 pm
Menu links in frame not working after I link to external site using IE January 18, 2008, 7:18 pm
Internet Explorer Bug? May 22, 2006, 6:05 pm
css & internet explorer January 10, 2008, 4:55 am
HTTP GET not working ...why? March 9, 2005, 7:05 pm
CSS not working with XHTML September 28, 2006, 2:07 am
CSS not working with XHTML September 28, 2006, 2:09 am
getAttribute ('id') Not Working December 5, 2006, 9:57 am
SSI working environment May 31, 2007, 10:23 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap