PDA

View Full Version : insert text into window from popup...?



homerUK
Nov 28th, 2002, 01:12 PM
hi,

I have a main window (an iFrame) called "iView". This allows users to submit text text.... I want them to be able to add some predefined text as well..... so they would click a link which opens up a new window with two sentances in it.

eg:

insert - "hello world"
insert - "testing123"

I can get these to be inserted as basic text using the following function:



function insertText(theText)
{
window.opener.iView.focus();
window.opener.iView.document.selection.createRange().text = theText;
}


then the sentance to insert would look like:

<a href="javascript:insertText('hello world');">Insert - hello world</a>

but...

I want to have the text inserted to be formatted... so when the sentance is selected from the popup window, it would add

"<b>Hello</b><em>World</em>"

or something similar......
when I add the above formatting to the link, it doesnt seem to work.

so the link would look like:

<a href="javascript:insertText('<b>Hello</b><em>World</em>');">Insert - hello world</a>

Any ideas??

Thanks.

Mr J
Nov 28th, 2002, 05:15 PM
Not sure if I fully understand your question but.... is this something like what you are after?


<script>
function hmm(txt){
oDIV.innerHTML+=txt
}
</script>

<a href="#null" onclick="hmm('Hello World')">Hello World</a><BR>
<a href="#null" onclick="hmm(' <b>Nice Day</b>')">Nice Day</a><BR>
<a href="#null" onclick="hmm(' <font color=\'Today\'>again</font>')">Today</a>

<div id="oDIV"></div>