18. maj 2003 - 20:55
Der er
2 kommentarer og
1 løsning
Print indholdet af en iframe
Hej
Hvordan printer jeg indholdet af en iframe?
I mit "hoveddokument" har jeg en knap med denne kode:
onclick="window.frames.edit1.focus();window.frames.edit1.print()
edit1 er id'et på min iframe.
Men når jeg printer, får jeg en border på som sættes på hele siden.
VH
Anders Thingholm
Hej igen
Ingen held med de sider...
Her er min kode:
*****
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Rich Text Editor</title>
<META HTTP-EQUIV="expires" CONTENT="Mandag den 30.juli 1999 23:00:00 GMT">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<link rel="STYLESHEET" type="text/css" href="css/editor.css">
<link rel="stylesheet" href="../css/main.css" type="text/css">
<script type="text/javascript" src="js/editor.js"></script>
<style>
img { border: 0; }
</style>
</head>
<body scroll="no" class="editorBody" group="group1">
<form name="mainForm">
<input type="hidden" name="pageid" value="MSHTML">
</form>
<script language="JavaScript">
<!--
function VisBilleder() {
parent.frames("topFrame").window.document.location.href = 'billeder.html';
top.top.frames("toolbar").window.document.showTop();
}
// -->
</script>
<script>
function validate(){
if (format == "HTML"){
saveFile();
} else {
alert("Du skal være i layout mode, for at gemme.\nFilen er ikke gemt.");
}
}
</script>
<table width="660" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td height="20" style="border-left: 1px solid #FFFFFF; border-right: 1px solid #FFFFFF;"></td>
</tr>
<tr>
<td height="20" class="title" style="border-left: 1px solid #FFFFFF; border-right: 1px solid #FFFFFF;">{header}</td>
</tr>
<tr>
<td height="20"><a href="java script:history.back();"><img src="../images/buttonArrowBack.gif" alt="Tilbage" width="8" height="8" border="0"></a></td>
</tr>
</table>
<!-- Toolbar starts here -->
<table id="editbar" class="coolBar" cellspacing="0" cellpadding="0" onclick="if (this._editor && this._editor.setFocus) this._editor.setFocus()" style="width: 650px">
<tr>
<td id="saveButton" class="coolButton" onclick="validate();" title="Gem dokument" nowrap style="width: 40px"><img src="images/save.gif" align="absmiddle" width="19" height="18"> Gem </td>
<td id="saveButton" class="coolButton" onclick="document.myEditor.focus();document.myEditor.print()" title="Print" nowrap style="width: 60px"><img src="images/print.gif" align="absmiddle" width="19" height="18">Print</td>
<td id="fontSelect" style="padding: 0;" title="Font Face">
<select onclick="doSelectClick('FontName',this);window.event.cancelBubble=true;"
onchange="doSelectClick('FontName',this);window.event.cancelBubble=true;editbar.focus()">
<option value="Arial">Arial
<option value="Arial Black">Arial Black
<option value="Comic Sans MS">Comic Sans MS
<option value="Courier New">Courier new
<option value="Times New Roman">Times New Roman
<option value="Trebuchet MS">Trebuchet MS
<option value="Verdana">Verdana
</select>
</td>
<td id="sizeSelect" title="Font Size">
<select onclick="doSelectClick('FontSize',this);window.event.cancelBubble=true;"
onchange="doSelectClick('FontSize',this);window.event.cancelBubble=true;editbar.focus();"
style="width: 40px;">
<option value="1">1
<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>
</td>
<td>
<object id="palette" type="text/x-scriptlet" data="colorPicker/colorPicker.htm" width="14" height="14"></object>
<script type="text/javascript" for="palette" event="onscriptletevent(name, eventData)">
switch(name) {
case "colorchange":
doFormat("ForeColor",eventData);
paletteToggle();
}
</script>
</td>
<td id="colorSelect" title="Color" class="coolButton" onclick="paletteToggle()">
<img src="images/paletteicon.gif" align="absmiddle" width="16" height="16">
</td>
<td class="coolButton" onclick="doFormat('Bold')" title="Fed (Alt + B)"><img src="images/bold.gif" width="16" height="16"></td>
<td class="coolButton" onclick="doFormat('Italic')" title="Kursiv (Alt + I)"><img src="images/italic.gif" width="16" height="16"></td>
<td class="coolButton" onclick="doFormat('Underline')" title="Understreg (Alt + U)"><img src="images/underline.gif" width="16" height="16"></td>
<td style="width: 4;"><span class="separator"></span></td>
<td class="coolButton" onclick="doFormat('JustifyLeft')" title="Venstre Juster"><img src="images/justifyleft.gif" width="16" height="16"></td>
<td class="coolButton" onclick="doFormat('JustifyCenter')" title="Centrer"><img src="images/justifycenter.gif" width="16" height="16"></td>
<td class="coolButton" onclick="doFormat('JustifyRight')" title="Højrejuster"><img src="images/justifyright.gif" width="16" height="16"></td>
<td style="width: 4;"><span class="separator"></span></td>
<td class="coolButton" onclick="doFormat('Outdent')" title="Ryk ud"><img src="images/outdent.gif" width="16" height="16"></td>
<td class="coolButton" onclick="doFormat('Indent')" title="Ryk ind"><img src="images/indent.gif" width="16" height="16"></td>
<td class="coolButton" onclick="doFormat('InsertHorizontalRule')" title="Horisontal Streg"><img src="images/hr.gif" width="16" height="16"></td>
<td style="width: 4;"><span class="separator"></span></td>
<td class="coolButton" onclick="doFormat('FormatBlock','<UL>')" title="Bullets"><img src="images/bulletedlist.gif" width="16" height="16"></td>
<td class="coolButton" onclick="doFormat('FormatBlock','<OL>')" title="Numbers"><img src="images/numberedlist.gif" width="16" height="16"></td>
<td class="coolButton" onclick="doFormat('CreateLink'); swapModes(); swapModes();" title="Link"><img src="images/createlink.gif" width="16" height="16"></td>
<td class="coolButton" onclick="doFormat('RemoveFormat')" title="Fjern Formatering"><img src="images/createlink.gif" width="16" height="16"></td>
</tr>
</table>
<!-- Toolbar ends here -->
<iframe id="edit1" src="richTextEditor.php" name="myEditor" onfocus="document.all.editbar._editor = window.frames[this.id];" style="width: 100%; height: 50%;"></iframe>
<div id="switchDiv"><a href="#" onclick="swapMode(this); return false;">Vis HTML</a></div>
<form id="postForm" action="{TARGET}" method="POST">
<input type="hidden" name="USERID1" value="{USERID1}">
<input type="hidden" name="USERID2" value="{USERID2}">
<input type="hidden" name="USERID3" value="{USERID3}">
<input type="hidden" name="body">
</form>
<script language="JavaScript">
initEditEditor('js/');
</script>
</body>
</html>
*****
Som du kan se prøver jeg med onclick="document.myEditor.focus();document.myEditor.print()"
Men den printer stadig en border rundt om det hele...