Last active
September 28, 2023 15:05
-
-
Save evagoras/dc50350427953afcdd50fcdbf12abaf2 to your computer and use it in GitHub Desktop.
Web-based Content Editor using IFrame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="checkbox" onclick="setMode(this.checked)"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cmdExec(cmd,opt) { | |
if (isHTMLMode) { | |
alert("Please uncheck 'Edit HTML'"); | |
return; | |
} | |
idContent.document.execCommand(cmd,"",opt); | |
idContent.focus(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="images/editor/Bold.gif" alt="Bold" onClick="cmdExec('bold')"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<iframe id="idContent" width="600" height="280"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isHTMLMode = false | |
function document.onreadystatechange() { | |
idContent.document.designMode = "On"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foreColor() { | |
var arr = showModalDialog("selcolor.asp","", _ | |
"font-family:Verdana; font-size:12; dialogWidth:45em; dialogHeight:24em" ); | |
if (arr != null) cmdExec("ForeColor",arr); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img alt="ForeColor" src="images/editor/fgcolor.gif" onClick="foreColor()"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
Dim numID | |
numID = Request.QueryString("ID") | |
%> | |
<iframe width="600" height="280" id="idContent" src="getContent.asp?ID=<%=numID%>"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="images/editor/imageLocal.gif" alt="Insert Local Image" onClick="insertImageLocal()"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function insertImageLocal() { | |
if (isHTMLMode) { | |
alert("Please uncheck 'Edit HTML'"); | |
return; | |
} | |
var sImgSrc = showModalDialog("selectImage.asp","", "dialogHeight: 500px; dialogWidth: 400px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;"); | |
if(sImgSrc!=null) cmdExec("InsertImage",sImgSrc); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setMode(bMode) { | |
var sTmp; | |
isHTMLMode = bMode; | |
if (isHTMLMode) { | |
sTmp = idContent.document.body.innerHTML; | |
idContent.document.body.innerText = sTmp; | |
} else { | |
sTmp = idContent.document.body.innerText; | |
idContent.document.body.innerHTML = sTmp; | |
} | |
idContent.focus(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SubmitContent() { | |
if (isHTMLMode) { | |
alert("Please uncheck 'Edit HTML'"); | |
return (false); | |
} | |
document.editor.YOUR_CONTENT.value = idContent.document.body.innerHTML; | |
document.editor.submit(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form name="editor" method="post" action="submit_editor.asp"> | |
<input name="YOUR_CONTENT" type="hidden" value=""> | |
<input type="button" name="Submit" value="Submit »" onclick="SubmitContent();"> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
Dim strContent | |
strContent = Request.Form("YOUR_CONTENT") | |
'write HTML source | |
Replace(Server.HTMLEncode(strContent), vbcrlf, "<br>") | |
'or simply render it on the browser | |
Response.Write(strContent) | |
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%Option Explicit%> | |
<% | |
Dim numID 'unique identifier passed through the IFrame | |
Dim strContent 'returned HTML source from database | |
numID = Request.QueryString("ID") | |
If numID <> "" Then | |
' do your database query and populate strContent | |
Response.Write(strContent) | |
End If | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://evagoras.com/2011/02/02/web-based-content-editor-using-iframe/