/    Sign up×
Community /Pin to ProfileBookmark

How to disable text selection

Hi Folks,

I have a HTML page (Header) where I have a text as ” Page 1 0f 5″. When I select the text the whole header is getting selected.

I had attached the html page so that you can have a clear idea.

When I click on the header and drag , the header moves to left and right and the the whole header gets selected…. But When I comment the div layer “page_no” then its ok..

Any ways to avoid this….

Thanks,

Suresh.H.V.

[upl-file uuid=b079508f-7b1d-411e-9234-bc449f2c5b82 size=1kB]topframe.zip[/upl-file]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@TNOJan 04.2007 — In Internet Explorer you can add the attribute: [B]onselectstart="return false"[/B] in whichever html element you want to have this property
Copy linkTweet thisAlerts:
@suresh_hvauthorJan 05.2007 — Hi Dude,

Thanks a lot..it really solved my problem. Will it work the same in all the browsers ????
Copy linkTweet thisAlerts:
@konithomimoJan 05.2007 — IE specific, and not recommended.
Copy linkTweet thisAlerts:
@felgallJan 05.2007 — document.onselectstart=new Function('return false');

works with IE5+, Netscape 6+, Opera 8+, Firefox and probably others that I haven't tested. Provided that Javascript is enabled and your visitor doesn't apply a user javascript to cancel it out.
×

Success!

Help @suresh_hv spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...