Forum Moderators: open

Message Too Old, No Replies

How do I stop a user from highlighting an image?

         

SethCall

2:08 am on Oct 14, 2002 (gmt 0)

10+ Year Member



When a user highlights an image in their browser (by "boxing" it), it causes the image to "gray", to indicate it has been selected.

Well, due to a feature on my website, the user would find this very frustrating on certain images, because they will be using an image to see what they are doing...

so is there anyway to stop it?

Thx!

keyplyr

2:44 am on Oct 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Code in stickymail...

Purple Martin

3:36 am on Oct 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



keplyr, could you post it publically please? Thanks :)

SethCall

4:17 am on Oct 14, 2002 (gmt 0)

10+ Year Member



From keyplyer:

Surround this in JS tags in the HEAD. It will stop Cut, Copy and Highlight. This may be what you're looking for.

function disableselect(e){
return false
}
function reEnable(){
return true
}

//if IE4+
document.onselectstart=new Function ("return false")

//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}

SethCall

5:02 am on Oct 14, 2002 (gmt 0)

10+ Year Member



cool thx! that worked like a charm
So.. does this interfere with clicking in general thogh?

I *do* want to implement onClick's and such..

Well, I guess I'll just find out, and Ill post here what happens...

keyplyr

6:19 am on Oct 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I didn't post the script initially because Bret has asked us not to post raw code anymore, but to rather use stickymail, or wait until an example type thread comes around again.

If I have misunderstood this, someone please set me straight.

SethCall

2:25 pm on Oct 14, 2002 (gmt 0)

10+ Year Member



*covers mouth*

whoops!

Yeah sorry for that then!

Purple Martin

10:48 pm on Oct 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



lol, OK guys, I remember Brett saying that now!

I think the idea was to post enough info to point people in the right direction so they could then solve the problem themselves, and therefore learn about the underlying concepts.

Posting straight code that people can copy'n'paste won't help them learn why the code does what it does.

Using stickymail with no hints made public won't help other WW users learn. WW is (among other things) a reference tool for everyone, and so we should try to post useful information.

So perhaps a suitable answer could have dropped a hint about using "onselectstart" for IE, and "onmousedown"/"onclick" for N6. Then people could work out the rest themselves.

And if I have misunderstood this, someone please set me straight. ;)

SethCall

3:55 pm on Oct 15, 2002 (gmt 0)

10+ Year Member



heh well.. i can understand that viewpoint to some degree.. i probbaly agree with it 80%