Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
How can I write to an IFRAME instead of opening new window?
Old 11-26-2004, 04:22 PM How can I write to an IFRAME instead of opening new window?
wvmlt's Avatar
Experienced Talker

Posts: 46
Trades: 0
I have some code to preview text entered in a textarea. It opens a new window for the preview but I'd like to write the preview to an iframe when the button is clicked. Can this be done? Here's the code for the preview window.

PHP Code:
<SCRIPT language=\"JavaScript\">
function ShowPreview()
{
 var hWndPreviewWindow = window.open(\"\",\"Preview\",\"width=400,height=250,scrollbars=yes,resizable=yes,status=0\");



    hWndPreviewWindow.document.open();
    hWndPreviewWindow.document.writeln('<HTML><HEAD><TITLE>Preview Message</TITLE></HEAD>');

    hWndPreviewWindow.document.writeln('<BODY BGCOLOR=\"lightyellow\">');
    hWndPreviewWindow.document.writeln('<B>This is how your post will look</B>');
    hWndPreviewWindow.document.writeln('<A HREF=\"javascript:window.close()\">Close Preview</A><BR><BR><BR>');
    


var Cont = document.msgform.message.value;
Cont = Cont.replace(/\[B]/ig,'<b>') 
Cont = Cont.replace(/\[\/B]/ig,'</b>')  
Cont = Cont.replace(/\[I]/ig,'<i>')
Cont = Cont.replace(/\[\/I]/ig,'</i>')
Cont = Cont.replace(/\[U]/ig,'<U>')
Cont = Cont.replace(/\[\/U]/ig,'</U>')




hWndPreviewWindow.document.writeln(Cont);
    hWndPreviewWindow.document.writeln('</BODY></HTML>');
    hWndPreviewWindow.document.close();
}

</SCRIPT>
<INPUT TYPE=BUTTON VALUE="
Preview" ONCLICK="javascript:ShowPreview()"
id=PreviewButton name=PreviewButton> 
wvmlt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-26-2004, 06:22 PM
Spud In Disguise's Avatar
Super Spam Talker

Posts: 808
Location: UK... where else?
Trades: 0
From the looks of it it's this line that needs to change:

Code:
hWndPreviewWindow.document.open();
You will need to name your iframe:

example
Code:
<i frame name="frameone" src="frame.htm"></iframe>
Sorry I'm not too sure wot you would replace that first line with though....
__________________

Please login or register to view this content. Registration is FREE
- Fansite

Please login or register to view this content. Registration is FREE
- Blog
Spud In Disguise is offline
Reply With Quote
View Public Profile Visit Spud In Disguise's homepage!
 
Reply     « Reply to How can I write to an IFRAME instead of opening new window?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25894 seconds with 12 queries