How to work with circumflex accent in html textarea? - html

I have textarea in HTML file and I need to work with circumflex accent, that means a user need to have an option to type characters like:
ŝĝĉ
If I try to type it now, it does nothing (it does not type anything). Where could be problem?
I already use:
<meta charset="UTF-8">
The other not common characters works well, for example:
ěščř

The issue was caused by js:
$(document).keydown(function (e)
{
var keycode1 = (e.keyCode ? e.keyCode : e.which);
if (keycode1 == 0 || keycode1 == 9) {
e.preventDefault();
e.stopPropagation();
}
});
the solution was the change to:
$(document).keydown(function (e)
{
var keycode1 = (e.keyCode ? e.keyCode : e.which);
if (keycode1 == 9) {
e.preventDefault();
e.stopPropagation();
}
});
Now it works well. It is possible to type the characters and it still escape the "tab".

Related

how to find the code that prevent wordpress text selection?

I know this may be stupid and simple question but I really need help
there,s a wordpress website that have been created by someone and there is a text copy protection that I have no Idea how he applied to the website . I checked wordpress plugins and even tried additional css code but none of them disable that text copy protection . How can I find the code or the thing that prevent text copy protection ?
thank u so much
website address : https://www.lanamind.com/
I have added two options and both are working for me.
If you want to achieve this using plugin All in one security plugin provides this option where you can add copy protection. A plugin will always be the better option for this feature and this plugin has many other settings to secure your site.
Take a look here:
If you don't want to use this plugin you can add this code in your PHP file. I have tested it and it is working.
function output_copy_protection_code() {
?>
<meta http-equiv="imagetoolbar" content="no"><!-- disable image toolbar (if any) -->
<script type="text/javascript">
/*<![CDATA[*/
document.oncontextmenu = function() {
return false;
};
document.onselectstart = function() {
console.log("here");
if (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password") {
return false;
}
else {
return true;
}
};
if (window.sidebar) {
document.onmousedown = function(e) {
var obj = e.target;
if (obj.tagName.toUpperCase() == 'SELECT'
|| obj.tagName.toUpperCase() == "INPUT"
|| obj.tagName.toUpperCase() == "TEXTAREA"
|| obj.tagName.toUpperCase() == "PASSWORD") {
return true;
}
else {
return false;
}
};
}
document.ondragstart = function() {
return false;
};
/*]]>*/
</script>
<?php
}
add_action('init', 'output_copy_protection_code');

Disable enter in input box

I have a textarea where it should not be possible to input line breaks by pressing enter. How can I disable enter in my textarea?
That is the code:
<textarea name="textarea" style="width:250px;height:150px;"></textarea>
Don't forget to use the keydown event instead of the click event
$("input").keydown(function(event) {
if (event.keyCode == 13) {
event.preventDefault();
}
});
If you use jquery in your web application you can do fallowing trick to disable enter key.
$('textarea').keydown(function(e) {
if(e.which == 13) { return false; }
});
else you can use this
document.getElementById('textarea_id').addEventListener('keydown', function(k){
if(k.keyCode == 13) return false;
});
I hope this will help you!
Use event.preventdefault and next do what you like. For example
<script>
$("textarea").click(function(event) {
if (event.keyCode == 13) {
event.preventDefault();
}
});
</script>

Prevent esc from stopping audio playback

So, I've got a web application running only on IE11. I use a windows media player control to play an audio file.
If the user presses escape on the page, the playing of the audio file is ended.
How can I prevent this?
<!DOCTYPE html>
<HTML>
<HEAD>
</HEAD>
<BODY>
<OBJECT CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">
<PARAM name="URL" value="http://sampleswap.org/samples-ghost/%20MAY%202014%20LATEST%20ADDITIONS/PUBLIC%20DOMAIN%20MUSIC/626%5Bkb%5Dbuster-brown-gonna-make-you-happy-1943.mp3.mp3">
</OBJECT>
</BODY>
</HTML>
Perhaps something like this to disable it
(document).keyup(function(e) {
if (e.keyCode == 27) { // escape key maps to keycode `27`
e.preventDefault();
return false;
}
});
Try using javascript. (If you using only IE it should be work)
document.attachEvent("onkeydown", keyHandler);
function keyHandler() {
if(event.keyCode == 27)
{
event.returnValue = false;
event.keyCode = 0;
break;
}
}
27 is ESC key value.
And, this is alternative way.
document.addEventListener("keydown",function(e){
var charCode = e.charCode || e.keyCode || e.which;
if (charCode == 27){
return false;
}
});

How to trigger an event after hitting Tab key in textbox

I want to trigger an event like displaying an alert message when I hit the Tab key inside a textbox.
<input type="text" />
$("input").blur(function (e) {
if (e.which == 9)
alert("Hurray!!!");
});
What I want to happen is that whenever I type inside a textbox then hit Tab it will do something.
Im using jquery1.7.2.min.js
I really don't know if Im doing it right.
For the demo http://jsfiddle.net/QfCpC/
$("input").keydown(function (e) {
if (e.which == 9)
alert("Hurray!!!");
});
Fiddle Demo
Will this help
$("input").live("keydown" , function (e) {
if (e.which == 9)
alert("Hurray!!!");
});
http://jsfiddle.net/QfCpC/3/
<input type="text" />
$("input").keydown(function (e) {
if (e.which == 9)
$('#someButton).trigger('click');//or you can directly call the handler also
});
$(document).ready(function() {
$("input").bind("keydown",function (e) {
if (e.which == 9)
alert("Hurray!!!");
});
});
demo here..
http://jsfiddle.net/QfCpC/
In order for the e.which parameter to be set properly, I believe it has to be called from a keydown event.
See the fiddle here. http://jsfiddle.net/QfCpC/2/
Try : http://jsfiddle.net/cEzLL/
$("input").keydown(function (e) {
if (e.keyCode === 9)
alert("Hurray!!!");
});
The reason is when u hit 'tab' two actions takes place
KeyUp for tab button
Blur action for Input type field
Now according to your code you are adding eventlistner to blur event ... and blur event doesn't have property of giving you key binding.
So in order to do this you need to bind "keydown".
$("input").keydown(function (e) {
if (e.which == 9)
alert("YEYYYYYYY!!!");
});

How to disable specific keyboard keys on a webpage?

I am developing a webpage using Wordpress 3.04, and I'm experiencing the following issue:
In this webpage, I implemented a script that changes the background image every 10 seconds or so. Now, when users press the Left Arrow and Right Arrow keys, it makes the background picture change back and forth accordingly, and messes up the rotation cycle.
This becomes a problem in the Contact Form section of the site, since users that might need to navigate left and right inside each field might end up changing the background pic instead.
I would also like to disable the "Enter" key, to avoid the form being sent if the users are not done writing their message.
I looked around and found this javascript code that didn't work:
document.onkeydown=function DisableCTRL(e)
{
var val=(document.all)?event.keyCode:event.which;
if(parseInt(val)==17)//CTRL
{
alert('Not Allowed!');
window.event.returnValue=false;
}
}
This JS code didn't work either:
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = stopRKey;
Any help will be greatly appreciated. Thanks!
I think, you should call stop() on the passed event, i.e.
document.onkeydown = function(e) {
if (e.keyCode == 17) {
alert('Not Allowed!');
e.stop();
}
};
and maybe use addEventListener(). I am not sure, intercepting the Ctrl key down will actually turn of Ctrl altogether. I guess, you need to intercept cursor left/right with the ctrlKey attribute set. For testing key events, see e.g. http://unixpapa.com/js/testkey.html.
PS. document.all: http://javascript.about.com/od/hintsandtips/a/worst_4.htm
You need to call e.preventDefault() to stop the event from going ahead.. I wrote this function to handle unwanted keys on a site recently:
PreventIllegalKeyPress = function (e) {
if (e.target) t = e.target; //Firefox and others
else if (e.srcElement) t = e.srcElement; //IE
if (e.keyCode == 116) { //prevent F5 for refresh
e.preventDefault();
}
if (e.keyCode == 122) { //F11 leave fullscreen
e.preventDefault();
} else if (e.altKey && e.keyCode == 115) { //Alt + F4
e.preventDefault();
} else if (e.altKey && e.keyCode == 37) { //Alt + left
e.preventDefault();
} else if (e.altKey && e.keyCode == 39) { //Alt + right
e.preventDefault();
} else if (e.ctrlKey && e.keyCode == 82) { //Ctrl + R (reload)
e.preventDefault();
}
if (!(t.tagName == 'INPUT')) {
if (e.keyCode == 13) { //enter
e.preventDefault();
}
if (e.keyCode == 8) { //backspace
e.preventDefault();
}
}};
Note the check for t.tagName == "INPUT". This makes sure that both enter and backspace keys are allowed in input field but no-where else.
Then in $(document).ready, paste the following snippet to call the function:
$(document).keydown(function (e) {
NFS.PreventIllegalKeyPress(e);
});
This works perfectly fine for me.