Php code kopiëren

Status
Niet open voor verdere reacties.

jipyboy

Gebruiker
Lid geworden
5 jul 2009
Berichten
41
Stel ik heb een PHP code gemaakt. Het is bijv. een wachtwoord generator.
maar ik wil er een vakje waarop je kan klikken en dat hij de code dan kopieert. Hoe doe ik dit?
 
scriptje

Bedoelde je zoiets?

(google is je beste vriend)

<!-- TWO STEPS TO INSTALL SELECT AND AUTO COPY:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original: Russ (NewXS3@aol.com) -->
<!-- Web Site: http://dblast.cjb.net -->

<!-- Begin
function copyit(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
therange=tempval.createTextRange()
therange.execCommand("Copy")
}
// End -->
</script>

</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<form name="it">
<div align="center">
<input onclick="copyit('it.select1')" type="button" value="Press to Copy the Text" name="cpy">
<p>
<textarea name="select1" rows="3" cols="25">
If this is highlighted, then it has been copied.
</textarea>
</div>
</form>


<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 1.21 KB -->
 
ff vraagje waarom wil je dat je PHP gekopieert wordt(lolz in deze zin schrijf je het zo) jij hebt toch de copyrigth ervan????????????????????????
 
In jouw zin is weinig correct gespeld.




@TS: wat wil je precies gekopieerd hebben?
 
Mijn vermoeden is een knopje die de inhoud van het veld verplaatst naar je klembord, alsof de user het veld geselecteerd heeft en "control+C" gedaan heeft?

Klinkt als javascript.
 
Mijn vermoeden is een knopje die de inhoud van het veld verplaatst naar je klembord, alsof de user het veld geselecteerd heeft en "control+C" gedaan heeft?

Klinkt als javascript.

Precies wat Frats bedoeld iemand een idee hoe ik dit moet doen??
 
dit is wat je zal willen denk ik maar ik heb de volledige code erbij geplaatst
let wel op id moet beschikbaar(bestaan) zijn en mag geen twee keer voorkomen

Code:
document.getElementById("Source").value = editorpanelname.innerHTML;



Code:
<script >
  var editorpanelname = document.getElementById("Editorpanel");//(-- W3C correction OK! --)
  doWYSIWYG('underline')
  function doWYSIWYG(command, condition, arg){
    //editorpanelname.focus();
    if(!condition) condition=false;
    document.execCommand(command, condition, arg);
  }
  function doWYSIWYG2(command, condition, arg){
   editorpanelname.focus();
   addPTag(editorpanelname, command);
  }
  function doWYSIWYG3(){

  }
  function getselectedtext(){
    var txt = '';
    if (window.getSelection){
        txt = window.getSelection();
    }else if (document.getSelection){
        txt = document.getSelection();
    }else if (document.selection){
        txt = document.selection.createRange().text;
    }else
	  return;
    return txt;
  } 
  var issource =false;
  function tosource(){
  	if (!issource){
  		document.getElementById("Source").value = editorpanelname.innerHTML;
  		issource = true;
  	}
  	
  	//switch to other vieuw
    setclass("Editorpanel",'hidden Apanel');
  	setclass("Sourcepanel",'Apanel');
  }
  function totexteditor(){
  	if (issource){
  		editorpanelname.innerHTML = document.getElementById("Source").value;
  		issource = false;
  	}  	
 	//switch to other vieuw
	setclass("Editorpanel",'Apanel');
  	setclass("Sourcepanel",'hidden Apanel');
  }
  function senddata(Field){
	tosource();
	document.getElementById("editor").submit();
  }
  function doselect(){
  		if(window.getSelection) {
			s.removeAllRanges();
			s.addRange(rng);
		} else {
			rng.select();
		}
  }
  function doresize(){
    var Y = document.getElementById('height').value;
    var X = document.getElementById('width').value;
    if(issize(X,Y)) { 
		alert("One or more of the dimensions entered cannot be supported. Setting defaults.");
		X="98%"; Y="350";
	}
	replacevalue("width",X);
	replacevalue("height",Y);
	editorpanelname.width=X;
	editorpanelname.height=Y;
  }
  //todo delete _moz_dirty if mozila
  function isbrowserok(){
  		if (navigator.userAgent.indexOf("Firefox")!=-1){
  			return true;
  		}else if(window.navigator.appName == "Microsoft Internet Explorer"){//you must use a better browser
			var IEversion = window.navigator.appVersion;
			alert(window.navigator.appName + "you must use a better browser for this function");
			return (IEversion.substring(IEversion.indexOf("MSIE") + 5, IEversion.indexOf("MSIE") + 8) >= 5.5)
		}else if(window.navigator.appName == "Netscape"){//&&(parseInt(appVersion)==4
		  	return true;	
		}else{//geen ondersteunde browser
			return false;
		}
   }
  	function issize(X,Y){
		var xlen = X.length;
		var xsub = X.substring(0,xlen-1);
		//-- take last char and lie %--&&-- max100 min50
		if((X.substring(xlen-1,xlen))=="%"&&(xsub>100||xsub<50)||X>screen.width||X<200||isNaN(xsub-1)){
			 return false;
		}
		var ylen = Y.length;
		if((Y.substring(ylen-1,ylen))=="%"||Y<200||isNaN(Y.substring(0,ylen-1))) {
			return false;
		}
		return true;		
	}
	function replacevalue(id,value){
			  document.getElementById(id).value=value;
	}
	function setclass(id,value){
			  document.getElementById(id).className=value;
	}
	var oldpanel;
	var selection ="";
	if (isbrowserok()){
		setclass("editERROR",'ERROR hidden');
	}else {
		setclass("editor",'');
	}
</script>
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan