11. december 2002 - 10:48
												Der er
									6 kommentarer													og
					1 løsning									
									
		 
		
			
Indsættelse af billede.i <div>
			Hvordan indsætter man et billede i <div></div> når man bruger funktionen.
function doImage()
  {
     iView.document.execCommand("insertimage", true, null);
  }
Det skal bruges til en online editor.
					
		
	 
		
								
					
				11. december 2002 - 11:20
				#2
						
		 
		
			oki men den er lang :)
<% @LANGUAGE="VBSCRIPT" %>
<%
dim objFSO, tmp
set objFSO = createobject("scripting.filesystemobject")
dim stHomePage
strHomePage = "valg.asp"
dim strFilePath
strFilePath = "./"
dim strScriptName
strScriptName = request.servervariables("script_name")
strScriptName = mid(strScriptName, instrrev(strScriptName, "/") + 1)
'***---
if request.form("update") = "" then
const fsoForReading = 1
dim objFile
objFile = request.querystring("fil")
dim objFileContents
set objFileContents = objFSO.OpenTextFile(server.mappath(strFilePath & objFile), fsoForReading)
dim strFileContents
strFileContents = objFileContents.ReadAll
else if request.form("update") <> "" then
dim strWriteContents
strWriteContents = request.form("iView")
if strWriteContents = "" then
strWriteContents = "Denne side er ikke tilgængelig."
strWriteContents = strNewContent & vbCrLf & "<br><br>"
strWriteContents = strNewContent & vbCrLf & "Vi undskylder ulejligheden."
end if
set objWriteFile = objFSO.OpenTextFile(server.mappath(strFilePath & request.form("file")), 2, true)
objWriteFile.write(strWriteContents)
objWriteFile.close
set objWriteFile = nothing
response.redirect strHomePage
end if
end if
%>
<%
if session("login") <> 1 then
    response.Redirect "../login.asp"
end if
%>
<html>
<head>
<title>Opdaterings editor</title>
<script language="JavaScript">
  function Init()
  {
    iView.document.designMode = 'On';
  }
  
      
  function doBold()
  {
    iView.document.execCommand('bold', false, null);
  }
  function doItalic()
  {
    iView.document.execCommand('italic', false, null);
  }
  function doUnderline()
  {
    iView.document.execCommand('underline', false, null);
  }
  
  function doLeft()
  {
    iView.document.execCommand('justifyleft', false, null);
  }
  function doCenter()
  {
    iView.document.execCommand('justifycenter', false, null);
  }
  function doRight()
  {
    iView.document.execCommand('justifyright', false, null);
  }
  function doOrdList()
  {
    iView.document.execCommand('insertorderedlist', false, null);
  }
  
  function indryk()
  {
    iView.document.execCommand('indent', false, null);
  }
  
  function udryk()
  {
    iView.document.execCommand('outdent', false, null);
  }
  function doBulList()
  {
    iView.document.execCommand('insertunorderedlist', false, null);
  }
  
  function doForeCol(fCol)
  {
    if(fCol != null)
      iView.document.execCommand('forecolor', false, fCol);
  }
  function doLink()
  {
    iView.document.execCommand('createlink');
  }
  
  function doImage()
  {
     iView.document.execCommand("insertimage", true, null);
  }
  
  function klip()
  {
    iView.document.execCommand('cut', false, null);
  }
  
  function satind()
  {
    iView.document.execCommand('paste', false, null);
  }
  
  function kopier()
  {
    iView.document.execCommand('copy', false, null);
  }
 
  function doFont(fName)
  {
    if(fName != '')
      iView.document.execCommand('fontname', false, fName);
  }
  
  function doSize(fSize)
  {
    if(fSize != '')
      iView.document.execCommand('fontsize', false, fSize);
  }
  
function over(element) {
element.style.borderStyle= "solid";
element.style.borderWidth = "1px";
element.style.borderColor = "#000000";
element.style.backgroundColor = "#F1F1F1";
element.style.cursor = "hand";
}
function out(element) {
element.style.borderColor = "#CCCCCC";
element.style.backgroundColor = "#CCCCCC"
element.style.cursor = "default";
}
function div2hidden(objForm) {
objForm.iView.value = document.all.tags('div')['iView'].innerHTML;
}
function go(where) {
window.location.href = where;
}
//-->
</script>
</script>
</head>
<body bgcolor="#FFFFFF"  onLoad="Init()">
<form name="frmedit" method="post" onsubmit="return div2hidden(this);" action="editor.asp">
<input type="hidden" name="iView" value="">
<input type="hidden" name="update" value="1">
<input type="hidden" name="file" value="<%= objFile %>">
  <table width="550" cellpadding="2" cellspacing="2" align="center" style="border-style: solid; border-width: 1px; border-color: #000000;" bgcolor="#CCCCCC">
<tr>
      <td width="100%" align="center">
        
        <input type="submit" value="Opdater">  
        <input type="button" value="Cancel" onclick="go('<%= strHomePage %>');">
      </td>
</tr>
<tr>
 <td>
 <table width="100%" cellpadding="0" cellspacing="0" border="1" bordercolor="#CCCCCC">
 <tr>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="klip()">
  <img src="img/klip.gif" alt="Klip - Ctrl + X">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="kopier()">
  <img src="img/kopier.gif" alt="Kopier - Ctrl + C">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="satind()">
  <img src="img/satind.gif" alt="Sæt ind - Ctrl + V">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="doBold()">
  <img src="img/fed.gif" alt="Fed - Ctrl + B">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="doItalic()">
  <img src="img/skraa.gif" alt="Skrå - Ctrl + I">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="doUnderline()">
  <img src="img/understreg.gif" alt="Understreg - Ctrl + U">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="doLeft()">
  <img src="img/venstre.gif" alt="Ret til venstre">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="doCenter()">
  <img src="img/centrer.gif" alt="Centrer">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="doRight()">
  <img src="img/hojre.gif" alt="Ret til højre">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="doOrdList()">
  <img hspace="2" vspace="1" src="img/talliste.gif" alt="Tal liste">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="doBulList()">
  <img hspace="2" vspace="1" src="img/punktliste.gif" alt="Punkt liste">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="indryk()">
  <img hspace="2" vspace="1" src="img/formindsk.gif" alt="Formindsk indrykning">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="udryk()">
  <img hspace="2" vspace="1" src="img/forog.gif" alt="Forøg indrykning">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="doLink()">
  <img hspace="2" vspace="1" src="img/link.gif" alt="Link - Ctrl + K">
  </div>
  </td>
  <td valign="center" align="center" onmouseover="over(this);" onmouseout="out(this);" width="20" height="20">
  <div onclick="doImage()">
  <img hspace="2" vspace="1" align="absmiddle" src="img/billede.gif" alt="Billede">
  </div>
  </td>
 </tr>
 <tr valign="middle">
  <td colspan="16" width="100%">
  <select onchange="doForeCol(this.options[this.selectedIndex].value);">
  <option value="0">Text farve</option>
  <option value="#000000">Sort</option>
  <option value="#FF0000">Rød</option>
  <option value="blue">Blå</option>
  </select>
   
  <select onchange="doFont(this.options[this.selectedIndex].value);">
  <option selected>Font</option>
  <option value="Arial">Arial</option>
  <option value="Times New Roman">Times New Roman</option>
  <option value="Verdana">Verdana</option>
  </select>
   
  <select onchange="doSize(this.options[this.selectedIndex].value);">
  <option selected>Størrelse</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  </select>
</td>
 </tr>
 </table>
 </td>
</tr>
<tr>
 <td align="center">
 <div contentEditable="true" id="iView" name="iView" style="border-style: solid; border-width: 1px; border-color: #000000; background-color: #FFFFFF; padding-left: 3px; padding-right: 3px; padding-top: 3px; padding-bottom: 3px; width: 550px; height: 400px;">
 <%= strFileContents %>
 </div>
 </td>
</tr>
<tr>
 <td width="100%" align="center">
 <input type="submit" value="Opdater">  
 <input type="button" value="Cancel" onclick="go('<%= strHomePage %>');">
 </td>
</tr>
</table>
</form>
<form method="POST" enctype="multipart/form-data" action="Upload.asp">
  <input type="file" name="fil">
  <input type="submit" value=" Upload ">
</form>
</body>
</html>
		
		
	 
	
		
								
					
				11. december 2002 - 12:56
				#3
						
		 
		
			Heysa !
Du skal sætte den i focus først...
  function doImage() {
      iView.focus();
    iView.document.execCommand("insertimage", true, null);
  }
Det er en god idé at gøre det ved alle...
Venligst
<ATN/>
		
		
	 
	
		
								
					
				11. december 2002 - 14:47
				#4
						
		 
		
			Det var jo næsten for nemt :) Tusind tak, jeg havde siddet længe med det "l'rt" rart at det endelig virker. kunne du evt fortælle mig hvordan nemmest kan laves således at brugeren kan browse igennem en mappe på serveren for derefter at sætte et billede ind på iView. Det kunne jo være smart :)