javascript Copy to clipboard
How Copy a Text to Clipboard JavaScript for IE.
Jak kopírovat text do schránky pomocí javascript pro Internet Explorer.
function ClipBoard()
{
// idText is ID some textarea with style display:none;
// idDivWithText is some div with text where will copied to
// clipoboard
idText.innerText = idDivWithText.innerText;
Copied = idText.createTextRange();
Copied.execCommand("RemoveFormat");
Copied.execCommand("Copy");
}
77LW NO topic_id
AD
Další témata ....(Topics)
toString([radix])
/* prevede objekt na string */
toLocaleString()
var myDate = new Date();
document.write( myDate.toLocaleString());
// 24. února 2009 10:50:02
valueOf()
var number = new Number();
number = Number(100);
if (!isNaN(number))
document.write(number.valueOf()); // 100
hasOwnProperty(proName)
var theObj = { prom : 'bla' };
if ( theObj.hasOwnProperty )
{
document.write( "Has 'prom': " + theObj.hasOwnProperty( 'prom' ) + 'n' ); // true
document.write( "Has 'prom2': " + theObj.hasOwnProperty( 'prom2' ) + 'n' ); // false
}
isPrototypeOf(object2)
function fc(){
var reg = new RegExp();
return (RegExp.prototype.isPrototypeOf(reg)); // return true.
}
propertyIsEnumerable(proName)
var a = new Array("apple", "banana", "cactus");
document.write(a.propertyIsEnumerable(2)); // true
Foreach fore each in javascript loop cycle example source code
Example code foreach for JavaScript.
var arr = new Array(1,2,3,4,5,6);// numbers or string put into array
for (var key in arr) {
window.alert("My array"
+ key
+ " = "
+ arr[key]);
}
// next example
arr.forEach(function(elem){
console.log(elem);
});
// next example
for (var i = 0; i < arr.length; i++) {
alert (arr[i]);
}
// next example for GECKO MOZILLA FIREFOX
var soucet = 0;
var obj = {var1: 5, var2: 13, var3: 8};
for each (var item in obj) {
soucet += item;
}
alert(soucet); // vysledek "26", coz je soucet 5+13+8
Each in jQuery get all document inputs type text and set value 0 if checkbox checked
function fc(th){
if( th.checked ){
$("input:text").each(
function() {
this.value = 0;
this.disabled = true;
}
);
}else{
$("input:text").each(
function() {
this.disabled = false;
}
);
}
<input type="checkbox" id="idCheck" onchange="fc(this);"> Checkbox
<input type="text" size="1" id="id1" value="0" />
<input type="text" size="1" id="id2" value="0" />
Někdy potřebujeme získat url adresu pro menu, nebo odkazy atd.
pozor funkce je empty() a ne emptyempty
pozor funkce je empty() a ne emptyempty
$currentURL = (!empty($_SERVER['HTTPS']))
? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']
: "//".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
Pro orientaci návštěvy na Vašem webu je tu funkce v PHP, která rozepíše cestu k právě otevřenému souboru do menu, kde jsou jednotlivé části odděleny dvojšipkou:
Path with arrows
Path with arrows - PHP functions make menu when is every folder on files path as links separated double arrows
function PathWithArrows () {
$root = '//moje-stranky.cz';
$cesta = explode('/', $_SERVER["PHP_SELF"]);
$cestaPomociSipek = "";
$home = "";
$n = 0;
foreach ($cesta as $str)
{
if($n == 0){
$home = '<a href="'.$root.'">home</a>';
$n++;
continue;
}
if($str !== ""){
$root .= '/'.$str;
$cestaPomociSipek .= ' » <a href="'.$root.'"> $str </a> ';
}
}
return $home.$cestaPomociSipek;
}
Toogle DIV javascript example code:
Jak skrýt, nebo zobrazit kontejner DIV:Nezapomeňte přiřadit DIVu ID, aby k němu bylo možno přistupovat pomocí getElementById a vše fungovalo i v jiných prohlížečích (Opera, Firefox, Google Chrome) a ne jen v Internet Exploreru.
<div id="idSomeDiv"> text div </div>
<input type="button" size="200" value="Skryj-zobraz"
onclick="var dH = document.getElementById('idSomeDiv');
if(dH.style.visibility == 'hidden') {
dH.style.visibility = 'visible';
} else {
dH.style.visibility = 'hidden';
}">
Editace: 18 10 2016
Počet článků v kategorii: 77
Url:javascript-copy-to-clipboard