Expanded version of "prompt" function?

W

wilsoncpu

I have a WYSIWYG editor (WidgEditor) I'm using on one of my sites.
It's nice, but the only function it has to enter an image into the
code being edited is a prompt box. ("Enter the location of the image",
and a text box.)
This works, but is in no way user-friendly. I could make a popup
window with a selection of thumbnails in it, and let them choose one,
at which point I can populate a text field in the popup window. I
suppose I could even copy that value to a hidden field inside the
opening file.
("opener.document.getElementById('imagepath')=this.getAttribute('imagechoice')").
But that sort of open isn't going to wait in the calling routine the
same way it does for a construct like:
var theImage = prompt("Enter the location for this image:", "");
if ([value of theImage is OK,proceed...]) ...

(a) Is there a way to build a replacement for the prompt that can be
customized the way I want, and still act like a prompt, with the
calling routine pausing until the prompt is satisfied?

(b) If not, are there any other suggestions?

I'm guessing this is basically a common problem, but I'm a bit
constrained by not wanting to completely re-write the WYSIWYG editor;
I'm just trying to add some helpful functionality for my users.
 
J

Joost Diepenmaat

wilsoncpu said:
var theImage = prompt("Enter the location for this image:", "");
if ([value of theImage is OK,proceed...]) ...

(a) Is there a way to build a replacement for the prompt that can be
customized the way I want, and still act like a prompt, with the
calling routine pausing until the prompt is satisfied?
No.

(b) If not, are there any other suggestions?

Make your own selector, and have it call
edited_document.execCommand("InsertImage",the_url,false);
I'm guessing this is basically a common problem, but I'm a bit
constrained by not wanting to completely re-write the WYSIWYG editor;
I'm just trying to add some helpful functionality for my users.

Most of the WYSIWYG editors are actually fairly small shells around the
browsers' build-in editors, which is where execCommand() is implemented.

See
http://www.mozilla.org/editor/midas-spec.html

http://msdn2.microsoft.com/en-us/library/ms537384(VS.85).aspx

Joost.
 
V

VK

I have a WYSIWYG editor (WidgEditor) I'm using on one of my sites.
It's nice, but the only function it has to enter an image into the
code being edited is a prompt box. ("Enter the location of the image",
and a text box.)

Even worser than that: in IE7 with default security settings prompt
dialog leads to security warning (yellow bar atop of page) "Active
content on this page is attempting to execute potentially dangerous
commands" - or something like that, I'm writing by memory.

So start forgetting ol' good window.prompt - it is not fully usable
anymore. If anyone is having current scripts with prompt usage?
immediately start to change them. That is my friendly suggestion not
to OP only but to anyone reading this post.
This works, but is in no way user-friendly.

And hell scary for IE7 users as explained above.
(a) Is there a way to build a replacement for the prompt that can be
customized the way I want, and still act like a prompt, with the
calling routine pausing until the prompt is satisfied?

Not exactly like that, but possible. You just have to split your
execution stream onto two parts:
Part 1 displays custom modal dialog and blocks user interaction with
anything outside of this dialog. On this step function is done and
exit.

Part 2 is the function that is being called on user interaction with
dialog (clicks etc.)

There is a number of DOM/CSS/Javascript based solutions of the kind,
the most stable out of my experience is subModal by "seth"
http://www.subimage.com/dhtml/subModal/
It has its own support forum at Google Groups (not Usenet!)
http://groups.google.com/group/subModal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,477
Members
44,898
Latest member
BlairH7607

Latest Threads

Top