det har jeg prøvet, jeg tror ikke det er nå jeg taster det ind der er problemer, men når jeg hænter det ind i formen det går galt for der hvor jeg taster det ind er der slet ingen felder, men bare ren html, prøv at se koden:
Først index.php
<html>
<head>
<title></title>
<script language="javascript">
bLoad=false
pureText=true
bodyTag="<BODY MONOSPACE STYLE=\"font:10pt arial,sans-serif\">"
bTextMode=false
public_description=new Editor
function Editor() {
this.put_html=SetHtml;
this.get_html=GetHtml;
this.put_text=SetText;
this.get_text=GetText;
this.CompFocus=GetCompFocus;
}
function GetCompFocus() {
Composition.focus();
}
function GetText() {
return Composition.document.body.innerText;
}
function SetText(text) {
text = text.replace(/\n/g, "<br>")
Composition.document.body.innerHTML=text;
}
function GetHtml() {
if (bTextMode)
return Composition.document.body.innerText;
else {
return Composition.document.body.innerHTML;
}
}
function SetHtml(sVal) {
if (bTextMode) Composition.document.body.innerText=sVal;
else Composition.document.body.innerHTML=sVal;
}
//End of Editor Class
/***********************************************
Initialize everything when the document is ready
***********************************************/
var YInitialized = false;
function _handleKeyDown () {
var ev = this.parentWindow.event
if(ev.keyCode == 13) {
var sel=Composition.document.selection.createRange();
sel.pasteHTML("<BR>");
sel.select();
ev.returnValue=false;
ev.cancelBubble=true;
}
}
/***********************************************
Initialize a button ontop of toolbar
***********************************************/
function InitBtn(btn) {
btn.onmouseover = BtnMouseOver;
btn.onmouseout = BtnMouseOut;
btn.onmousedown = BtnMouseDown;
btn.onmouseup = BtnMouseUp;
btn.ondragstart = YCancelEvent;
btn.onselectstart = YCancelEvent;
btn.onselect = YCancelEvent;
btn.YUSERONCLICK = btn.onclick;
btn.onclick = YCancelEvent;
btn.YINITIALIZED = true;
return true;
}
// Hander that simply cancels an event
function YCancelEvent() {
event.returnValue=false;
event.cancelBubble=true;
return false;
}
// Toolbar button onmouseover handler
function BtnMouseOver() {
if (event.srcElement.tagName != "IMG") return false;
var image = event.srcElement;
var element = image.parentElement;
// Change button look based on current state of image.- we don't actually have chaned image
// could be commented but don't remove for future extension
if (image.className == "Ico") element.className = "BtnMouseOverUp";
else if (image.className == "IcoDown") element.className = "BtnMouseOverDown";
event.cancelBubble = true;
}
// Toolbar button onmouseout handler
function BtnMouseOut() {
if (event.srcElement.tagName != "IMG") {
event.cancelBubble = true;
return false;
}
var image = event.srcElement;
var element = image.parentElement;
yRaisedElement = null;
element.className = "Btn";
image.className = "Ico";
event.cancelBubble = true;
}
// Toolbar button onmousedown handler
function BtnMouseDown() {
if (event.srcElement.tagName != "IMG") {
event.cancelBubble = true;
event.returnValue=false;
return false;
}
var image = event.srcElement;
var element = image.parentElement;
element.className = "BtnMouseOverDown";
image.className = "IcoDown";
event.cancelBubble = true;
event.returnValue=false;
return false;
}
// Toolbar button onmouseup handler
function BtnMouseUp() {
if (event.srcElement.tagName != "IMG") {
event.cancelBubble = true;
return false;
}
var image = event.srcElement;
var element = image.parentElement;
if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()");
element.className = "BtnMouseOverUp";
image.className = "Ico";
event.cancelBubble = true;
return false;
}
// Check if toolbar is being used when in text mode
function validateMode() {
if (! bTextMode) return true;
alert('Fravælg venligt "Vis HTML kilde" for at benytte værktøjslinjen');
Composition.focus();
return false;
}
function sendHtml(){
if(bTextMode){
document.composeForm.body.value = public_description.get_text();
return true;
}
else{
document.composeForm.body.value = public_description.get_html();
return true;
}
}
//Formats text in composition.
function formatC(what,opt) {
if (!validateMode()) return;
if (opt=="removeFormat") {
what=opt;
opt=null;
}
if (opt==null) Composition.document.execCommand(what);
else Composition.document.execCommand(what,"",opt);
pureText = false;
Composition.focus();
}
//Finds and returns an element.
function getEl(sTag,start) {
while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement;
return start;
}
function createLink() {
if (!validateMode()) return;
var isA = getEl("A",Composition.document.selection.createRange().parentElement());
var str=prompt("Skriv URLen:", isA ? isA.href : "http:\/\/");
if ((str!=null) && (str!="
http://")) {
if (Composition.document.selection.type=="None") {
var sel=Composition.document.selection.createRange();
sel.pasteHTML("<A HREF=\""+str+"\">"+str+"</A> ");
sel.select();
}
else formatC("CreateLink",str);
}
else Composition.focus();
}
//Sets the text color.
function foreColor() {
if (! validateMode()) return;
var arr = showModalDialog("/ym/ColorSelect?3", "", "font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:35em");
if (arr != null) formatC('forecolor', arr);
else Composition.focus();
}
//Sets the background color.
function backColor() {
if (!validateMode()) return;
var arr = showModalDialog("/ym/ColorSelect?3", "", "font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:35em");
if (arr != null) formatC('backcolor', arr);
else Composition.focus()
}
function save() {
SetText("test");
}
function printit() {
parent.main.focus();
parent.main.print();
}
function gem() {
parent.main.focus();
var nummer = GetHtml();
window.open('gem.php?data=' + nummer);
}
</script>
</head>
<body bgcolor="#000000" topmargin="30" leftmargin="30">
<table cellspacing="2" cellpadding="0" border="0" align="center" width="600">
<tr>
<td bgcolor="white" valign="top">
<form method="get" target="_blank" name="composeForm" action="gem.php">
<table width="100%" border="0" cellspacing="1" cellpadding="0" >
<tr>
<td> </td>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>
<div id="ParaToolbar">
<select id="FontName" language="javascript" onChange="formatC('fontname',this[this.selectedIndex].value);this.selectedIndex=0">
<option class="heading" selected>Skrifttype
<option value="Arial">Arial
<option value="Arial Black">Arial Black
<option value="Arial Narrow">Arial Narrow
<option value="Comic Sans MS">Comic Sans MS
<option value="Courier New">Courier New
<option value="System">System
<option value="Times New Roman">Times New Roman
<option value="Verdana">Verdana
<option value="Wingdings">Wingdings
</select>
<select id="FontSize" language="javascript" onChange="formatC('fontsize',this[this.selectedIndex].value);this.selectedIndex=0">
<option class="heading" selected>Strørrelse
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
<option value="5">5
<option value="6">6
<option value="7">7
</select>
<select id="FontColor" language="javascript" onChange="formatC('forecolor',this[this.selectedIndex].value);this.selectedIndex=0">
<option class="heading" selected>Farve
<option value="red">Rød
<option value="blue">Blå
<option value="green">Grøn
<option value="black">Sort
</select>
<select id="FontBackColor" language="javascript" onChange="formatC('backcolor',this[this.selectedIndex].value);this.selectedIndex=0">
<option class="heading" selected>Baggrund
<option value="red">Rød
<option value="blue">Blå
<option value="green">Grøn
<option value="black">Sort
<option value="yellow">Gul
<option value="white">Hvid
</select>
</div>
<table>
<tr>
<td><div language="javascript" onClick="formatC('cut')"><img src="images/cut.gif"></div></td>
<td><div language="javascript" onClick="formatC('copy')"><img src="images/copy.gif"></div></td>
<td><div language="javascript" onClick="formatC('paste')"><img src="images/paste.gif"></div></td>
<td><div tlanguage="javascript" onClick="formatC('bold');"><img src="images/bold.gif"></div></td>
<td><div language="javascript" onClick="formatC('italic')"><img src="images/italic.gif"></div></td>
<td><div language="javascript" onClick="formatC('underline')"><img src="images/under.gif"></div></td>
<td><div name="Justify" language="javascript" onClick="formatC('justifyleft')"><img src="images/aleft.gif"></div></td>
<td><div name="Justify" language="javascript" onClick="formatC('justifycenter')"><img src="images/center.gif"></div></td>
<td><div name="Justify" language="javascript" onClick="formatC('justifyright')"><img src="images/aright.gif"></div></td>
<td><div language="javascript" onClick="formatC('insertorderedlist')"><img src="images/nlist.gif"></div></td>
<td><div language="javascript" onClick="formatC('insertunorderedlist')"><img src="images/blist.gif"></div></td>
<td><div language="javascript" onClick="formatC('outdent')"><img src="images/ileft.gif"></div></td>
<td><div language="javascript" onClick="formatC('indent')"><img src="images/iright.gif"></div></td>
<td><div language="javascript" onClick="createLink()"><img src="images/wlink.gif"></div></td>
</tr>
</table>
<IFRAME NAME="main" ID="Composition" FRAMEBORDER=1 border=0 scrolling=yes WIDTH="400" HEIGHT="400" SRC="test.php"></IFRAME>
<input type="hidden" name="content">
<script><!--
Composition.document.designMode="On";
// -->
</script>
<input type="submit" onClick="InsertText()" value="Ret startside">
<script language="JavaScript" type="text/javascript">
function InsertText(){
document.composeForm.content.value = Composition.document.body.innerHTML;
}
</script>
</form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
<td><a href="java script:gem()">Gem Ændringerne</a>
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<FORM>
</FORM>
</tr>
</table>
</body>
</html>
*************
test.php :
<HTML>
<BODY>
</BODY>
</HTML>