Let's say I have a textfield... is there a way to HIDE the blinking text cursor? I say this because I am doing a horror/mystery website and one of the clues is to start typing anywhere. Get it? :P
Maybe i can do it with javascript?
Let's say I have a textfield... is there a way to HIDE the blinking text cursor? I say this because I am doing a horror/mystery website and one of the clues is to start typing anywhere. Get it? :P
Maybe i can do it with javascript?
<input type='text' disabled='disabled' />
Edit:
That disables the textbox effectively removing the blinking cursor.. then I suppose you could use javascript to capture the keypresses and change the value of the textfield
document.onkeypress = functionThatChangesValue;
if (document.layers)
document.captureEvents(event.keypress);
Unfortunately you can not style the text cursor with CSS. You can only do some very bad JavaScript tricks but depending on the layout and requirements of your website, it might not be possible at all. So I would recommend to forget the whole idea.
Try this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title >Text Area with no Carat</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<style type="text/css">
.textarea-wrapper {
position:relative;
}
.textarea-wrapper textarea {
background-color:white;
}
.textarea-wrapper, .textarea-wrapper textarea {
width:500px;
height:500px;
}
.textarea-wrapper textarea.hidden {
color:white;
opacity:0.00;
filter:alpha(opacity=00);
position:absolute;
top:0px;
left:0px;
}
</style>
<script type="text/javascript">
$(document).ready(
function() {
$("textarea").addClass("-real-textarea");
$(".textarea-wrapper").append("<textarea class=\"hidden\"></textarea>");
$(".textarea-wrapper textarea.hidden").keyup(
function() {
$(".textarea-wrapper textarea.-real-textarea").val($(this).val());
}
);
$(".textarea-wrapper textarea.-real-textarea").focus(
function() {
$(this).parent().find("textarea.hidden").focus();
}
);
}
);
</script>
</head>
<body>
<div class="textarea-wrapper">
<textarea></textarea>
</div>
</body>
</html>
The idea is to create a second, invisible <textarea>
over/on-top-of the real one. The user is typing in the invisible one but the text doesn't appear (nor the carot/cursor) as it is invisible! You then use JavaScript to assign its value to the visible one.
But it doesn't seem to work in IE8 :'( the carot is still visible even though the opacity is cranked up to 11.
But it works in Firefox... ?
There is an easy way to do this with jQuery.
$(<textbox selector>).bind("focus", function() {
return false;
});
When a focus event occurs (what will start the cursor) you just capture it and ignore it.