PDA

View Full Version : Loose Focus/no Focus onclick set focus to nothing/opening a page where there is none!



ismailc
01-19-2008, 12:28 PM
Hi, I would like to do the following.

I have an href where onclick the focus is on the href:
I got it to change focus to another object but i don't really want that.

It must be as if the user clicked nothing. The href is what i use for my tooltip so it's only surppose to work onmouseover!

This is the jscript:
onClick="document.getElementById('__Submit').focus();"

The __Submit' is another object - i' setting the focus to


XSLT code i'm using:
<a>
<xsl:attribute name='href'>#</xsl:attribute>
<xsl:attribute name='rel'>ttip_<xsl:value-of select='@name' /></xsl:attribute>
<xsl:attribute name='onClick'>document.getElementById('__Submit').focus();</xsl:attribute>
<img src="images/help.jpg" align="texttop" style='border : none;'></img>
</a>

Please Help!

Regards

jscheuer1
01-19-2008, 02:34 PM
I'm not familiar with this XSLT stuff, but it looks fairly straightforward. Assuming all of your other code is valid and working:


<a>
<xsl:attribute name='href'>#</xsl:attribute>
<xsl:attribute name='rel'>ttip_<xsl:value-of select='@name' /></xsl:attribute>
<xsl:attribute name='onClick'>document.getElementById('__Submit').focus();return false;</xsl:attribute>
<img src="images/help.jpg" align="texttop" style='border : none;'></img>
</a>

will cancel the link's normal behavior of navigating to, in this case - '#'.

However, I see a potential problem in that onClick isn't strictly an attribute, and if treated exclusively as one, it probably won't fire.

ismailc
01-19-2008, 02:55 PM
Hi, Thank You for the help!

But unfortunately it still sets the focus to the __Submit.

No error nothing - it moves the focus to the ___Submit.

Please Assist!

Regards

jscheuer1
01-19-2008, 04:58 PM
I misunderstood because it seemed like you wanted the focus to shift. If you want the link to do nothing:


<a>
<xsl:attribute name='href'>#</xsl:attribute>
<xsl:attribute name='rel'>ttip_<xsl:value-of select='@name' /></xsl:attribute>
<xsl:attribute name='onClick'>return false;</xsl:attribute>
<img src="images/help.jpg" align="texttop" style='border : none;'></img>
</a>

This still assumes that the onClick will fire, which - if you were having the focus shift on you, it will. Just now though, when it fires, it won't do anything, not even navigate. Any onmouseover characteristics that are assigned to it by other code should still work.

ismailc
01-19-2008, 05:41 PM
Hi, Thank you for the assist!

The link does nothing but i want the focus to move off the href(image) as
i want the user not be able to click on the image.

because when click it sets focus to the image with a border around it!

I'm using the href for the soultion to the tooltip problem i had!
where the user just mouseover & tooltip will display!

but now becuase is changed to an href - user can click & image/href as focus
i actually want it not to have focus

- can i maybe disable the onclick - as in no click?
This was used to move focus off the href but now i can't find anything else to hide the focus!
<xsl:attribute name='onClick'>document.getElementById('___Submit').focus();return false;</xsl:attribute>

jscheuer1
01-19-2008, 06:47 PM
With border:none; for the image, there should be no border. I think you may be referring to the outline. Try:


<a style="outline-style:none;">
<xsl:attribute name='href'>#</xsl:attribute>
<xsl:attribute name='rel'>ttip_<xsl:value-of select='@name' /></xsl:attribute>
<xsl:attribute name='onClick'>return false;</xsl:attribute>
<img src="images/help.jpg" align="texttop" style='border : none;outline-style:none;'></img>
</a>

Since this is xsl though, you may need to put style in an xsl stylesheet.

But, no matter what you do, people can click anywhere they like. All you can do is configure what happens when they do. Browsers can still override that with user defined settings.

Now, if the tip didn't depend upon a link, I'd use a span. From your code it looks like a link is required - rel isn't an attribute of span, and the tip code may only be looking at links.

There are other tool tip scripts that can work with any element though.

Another thing to try:


<a>
<xsl:attribute name='href'>#</xsl:attribute>
<xsl:attribute name='rel'>ttip_<xsl:value-of select='@name' /></xsl:attribute>
<xsl:attribute name='onClick'>this.blur();return false;</xsl:attribute>
<img src="images/help.jpg" align="texttop" style='border : none;'></img>
</a>

ismailc
01-21-2008, 06:50 AM
Hi, Thank You very much for your kindness & help - Great stuff

I found that i had to add the onBlur as it did not work without that!

code:
<a style="outline-style:none; cursor:default;">
<xsl:attribute name='href'>#</xsl:attribute>
<xsl:attribute name='rel'>ttip_<xsl:value-of select='@name' /></xsl:attribute>
<xsl:attribute name='onClick'>this.blur();return false;</xsl:attribute>
<img src="images/help.jpg" align="texttop" border="0" style='border : none; cursor:default; outline-style:none;'></img>
</a>

Thank You !!!

Regards