Jump to content

Text not displaying in the iframe???


cturner

Recommended Posts

I am trying to build a rich text editor for a client of mine. However I can only get the text from the database to be displayed every where else but the iframe. Can someone please help me get the text into the iframe? Thanks in advance.

 

// the getting text from the database code
<?php
require "config.php";
$query = mysql_query ("SELECT * FROM tbl_articles") or die ("Could not query because: ".mysql_error());
$row = mysql_fetch_assoc($query);
$id = $row['id'];
$article = $row['article'];'
?>
// the iframe
<iframe id="textEditor" name="textEditor" style="width:500px; height:200px;"></iframe>
// the code to display the text in the iframe
<script language="javascript">
textEditor.document.designMode="on";
textEditor.document.open();
textEditor.document.write('<head><style type="text/css">body{ font-family:verdana; font-size:10px; }</style></head>');
textEditor.document.write( </script> <?php echo $article; ?> <script language="javascript"> );
textEditor.document.close();
</script>
// close the database
<?php mysql_close(); ?>

Link to comment
Share on other sites

I've not tried this when using an iframe for RTE purposes, but what about setting up a script that takes an article ID through $_GET and displays the article.  Then you could just set the src attribute of the iframe to that script.

Link to comment
Share on other sites

I had tried what you said Dj Kat but that didn't work. Anyway I tried <iframe id="textEditor" name="textEditor" src="<?php echo 'http://www.blueguminteractive.biz/myrte/phppage.php'; ?>" style="width:500px; height:200px;"></iframe> that worked for me. The phppage.php has the code for getting the article.

 

Now there is another problem the iframe is not editable. Is there a way to make the iframe editable?

Link to comment
Share on other sites

Assign an onload handler to the iframe that sets the designMode property to "on".  Take note there are differences between IE and Mozilla as to which object is the owner of designMode.

 

If you follow the link in my signature I have a couple of blog posts about creating RTEs with Javascript.  I can't guarantee that it'll help you but it might.

Link to comment
Share on other sites

I remembered answering a similar question check this link out it might help

http://www.phpfreaks.com/forums/index.php/topic,147397.0.html

 

<iframe id="textEditor" name="textEditor" src="<?php echo 'http://www.blueguminteractive.biz/myrte/phppage.php'; ?>"

 

I think that won't work btw since your iframe will contain the text editor

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.