@popcans
Although I have no experience with popups, I have a few suggestions:
- Maybe mootools.js should be included in the popup page? IE might not
like using MooTools methods on pages without it.
- Maybe also IE doesn't like adding a whole page to a popup once it's
popped up (I'm thinking adding a "html" tag might confuse it). Maybe
it would be better to have a fixed page, say at chat.html, that
contains everything you otherwise wrote using doc.write, and then use
window.open('chat.html',... or similar to open it. (This would also
mean you're not using doc.write!)
@electronbender
Although I would agree that popups are generally bad, maybe a chat
popup is an exception: I would expect it to remain open even if I went
to other pages. What do you think?
Michal.
On Dec 30, 3:46 pm, popcans <[email protected]> wrote:
> Show me another way to create the popup window that would give me
> access to the dom and I'll do it. I tried to access parts of it
> without doing the write command. The only way I could get it to work
> was to use the write command. I am not a novice here, I have been
> doing javascript and using mootools for a long time. I know how to do
> good programming. A modal window is not going to work for what I am
> doing. I have a roster window, and when you click on a member of the
> roster it opens a chat window, just like any other chat application
> out there. I am not really asking for a critique on my code, I am
> asking for help in solving a problem.
>
> On Dec 30, 9:57 am, electronbender <[email protected]> wrote:
>
> > That is not good programing, you should avoid .write statements.
> > And may i recommend using a modal window instead of opening a popup
> > winow?
>
> > On Dec 29, 6:49 pm, popcans <[email protected]> wrote:
>
> > > I am creating an instant messenger chat application. I have a roster
> > > window, and when I click on a member of the roster to send them a
> > > message it opens a chat window. I use the function below to create the
> > > chat window. This function returns an object with references to all
> > > the elements I need to work with. Every browser seems to work fine,
> > > except of course for Internet Explorer. IE won't let me insert
> > > anything into the elements. I could, oddly enough get it to allow me
> > > to set the text of an element, but I couldn't get the elements to
> > > adopt any new elements. Not sure if this is enough information, but I
> > > would appreciate any help anyone can give.
>
> > > function buildChatWindow(recipient)
> > > {
> > > /** open a new window for the chat application */
> > > if (!chatWindow || chatWindow.closed){
> > > /** create the window */
> > > chatWindow = window.open('', 'IV5_Chat',
> > > 'scrollbars=1,toolbar=0,menubar=0,resizable=1,status=0,location=0,left=250,
> > > top=50,width=500,height=400');
>
> > > /** get the document */
> > > doc = chatWindow.document;
> > > doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
> > > Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
> > > transitional.dtd"><html xmlns="http://www.w3.org/1999/
> > > xhtml"><head><meta http-equiv="Content-Type" content="text/html;
> > > charset=UTF-8" /><title>IV5 Chat</title><!-- Load Chat Styles And
> > > Javascript --><link rel="stylesheet" media="screen" type="text/css"
> > > href="/css/IV5.css" /><link rel="stylesheet" media="all" type="text/
> > > css" href="/apps/Chat/Assets/css/Chat.css" /></head><body><div
> > > id="Chat_ListArea"><ul id="Chat_List"></ul></div><div
> > > id="Chat_MessageArea"></div><div id="Chat_TextArea"><textarea
> > > id="Chat_Text" cols="1" rows="2"></textarea><input type="hidden"
> > > id="Chat_Recipient" value="" /></div></body></html>');
> > > doc.close();
> > > } else doc = chatWindow.document;
>
> > > /** give the window focus */
> > > chatWindow.focus();
>
> > > /** get the element references */
> > > head = $(doc.getElementsByTagName('head')[0]);
> > > title = $(doc.getElementsByTagName('title')[0]);
> > > body = $(doc.getElementsByTagName('body')[0]);
> > > chatListArea = $(doc.getElementById('Chat_ListArea'));
> > > chatList = $(doc.getElementById('Chat_List'));
> > > chatMessageArea = $(doc.getElementById('Chat_MessageArea'));
> > > chatTextArea = $(doc.getElementById('Chat_TextArea'));
> > > chatText =
> > > $(doc.getElementById('Chat_Text')).removeEvents().addEvent
> > > ('keypress', function(e){
> > > event = new Event(e);
> > > if (!event.shift && event.key == 'enter' &&
> > > this.value.length > 0){
> > > sendMessage(chatRecipient.value, chatText.value,
> > > chatMessageArea);
> > > }
> > > }).addEvent('keyup', function(e){
> > > event = new Event(e);
> > > if (!event.shift && event.key == 'enter' &&
> > > this.value.length > 0)
> > > this.value = '';
> > > });
> > > chatRecipient = $(doc.getElementById('Chat_Recipient'));
>
> > > /** check for recipient */
> > > if (recipient) chatRecipient.value = recipient;
>
> > > /** set the focus on the textarea */
> > > (function(){ chatText.focus(); }).delay(1000);
>
> > > /** return the parts */
> > > return {'head': head, 'title': title, 'body': body,
> > > 'chatListArea':
> > > chatListArea, 'chatList': chatList, 'chatMessageArea':
> > > chatMessageArea, 'chatTextArea': chatTextArea, 'chatText': chatText,
> > > 'chatRecipient': chatRecipient};
>
> > > }