...

View Full Version : New Window function with a div



feras_wilson
08-15-2005, 10:42 AM
Hi!
I have an newwindow function (function newwin()) but its don't work why?



<html>

<head>
<meta http-equiv="Content-Language" content="sv">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="visa.htm">
<title>fghfghgfhgfhfgh</title>
<script>
function wrapSelection(isTag){

document.getElementById('tpip');
workText = document.selection.createRange();
if (document.selection.type == 'Text')
{workText.pasteHTML("<"+isTag+">"+workText.text+"</"+isTag+">")

}

}
function Undo(theField) {
var tempval=eval("document."+theField)
if (document.all){
tempval.focus()
document.execCommand("Undo")
}
}

function newWin() {
var html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\
<html>\
<head>\
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\
<title></title>\
</head>\
<body>\
<p>Tryck på Arkiv och sen Spara som. Här är din text:</p>\
'+ document.jj.tpip +'\
</body>\
</html>\
';
var win = window.open();
win.document.open();
win.document.write(html);
win.document.close();
win.focus();
}

</script>
</head>

<body>
<form name="jj">
<Div id='tpip' contenteditable style='width:533px;height:362px;border:1px solid black;overflow:auto'>
fghfghgfhgfhfgh</Div></form>
<a href="#" name="ll" onclick="wrapSelection('b')">hfg</a>
<a href="#" name="ll" onclick="wrapSelection('h1')">indexbold</a>
<select size="1" name="D1" onchange="wrapSelection(this.value)">
<option value="h1" selected>h1</option>
<option value="h2">h2</option>
<option value="h3">h3</option>
<option value="h4">h4</option>
<option value="h5">h5</option>
<option value="h6">h6</option>
</select>
<a href="#" onclick="Undo('jj')">undo</a>
<a href="#" onclick="newWin()">SAVE</a>
</body>

</html>

Please Help! :confused:

martin_narg
08-15-2005, 03:59 PM
change this line:


'+ document.jj.tpip +'\

to this:


'+ document.getElementById("tpip").innerHTML +'\


You should know that your code is not cross-browser compatible. If you require further help with this, please repost.

Hope this helps

m_n



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum