textarea....adding images for blogging

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
phpMover
Forum Newbie
Posts: 3
Joined: Sat Feb 02, 2008 6:37 am

textarea....adding images for blogging

Post by phpMover »

how could i work with the textarea that will accept pictures or links. If javascript give me a hint.
i will be using it for blogging. and i am a newbie for doing it. I needed your help masters, to enable images in the textarea thank you so much. I am looking forward for help replies.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: textarea....adding images for blogging

Post by pickle »

Impossible. A text area is just that - an area for plain text. Your best bet is to not reinvent the wheel & use a WYSIWYG editor like FCKEditoror TinyMCE.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: textarea....adding images for blogging

Post by Jonah Bron »

Just out of curiosity, what is the general method behind those?
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Re: textarea....adding images for blogging

Post by Inkyskin »

I think they use Javascript to render html etc where the textbox would normally go
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: textarea....adding images for blogging

Post by pickle »

tinyMCE & FCKEditor plop an iframe overtop the textbox I believe.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: textarea....adding images for blogging

Post by Jonah Bron »

Interesting. And how do they enable you to edit?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: textarea....adding images for blogging

Post by pickle »

That's a very obvious question - one that I've never asked myself before and don't have an answer to.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: textarea....adding images for blogging

Post by alex.barylski »

~pickle | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


WYSIWYG editors work by basically replacing (actually hiding) the TEXTAREA and inserting a IFRAME.

The IFRAME is then told to turn into "edit" mode - how this is done might vary from browser to browser but most will work by setting the "document" editMode property to on.

Code: Select all

document.getElementById("wysiwyg_iframe").editMode = "on";
Something to that effect anyways, Google edit mode and you'll see...

Thing get interesting in their own unique implementations which counter-attack browser caveats. For instance, under IE (5 anyways it's been a while since I did this) UNDO would stop working in most WYSIWYG (HtmlArea) because HtmlArea (if memory serves correct) updated the TEXTAREA each time a key was pressed - updating the textarea it turns out - erased the internal UNDO buffer.

This was eventually rectified by capturing the onsubmit() event and updating the textarea only at submittion time - at least thats how we fixed the problem.

Then of course, there are the infamous double line break in IE - which requires a wicked buggy hack or the user to hold down the shift key when pressing enter if only a single line break is desired.

With all the browser caveats...and difficult manipulation of the browser and it's DOM via javascript...those were the worst most irritating moments of my life. Something works one moment and then because of a cache issue or something similar BAM the code doesn't work on next refresh.


~pickle | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply