textarea in a popped window

J

jessbody

The following javascript code (used as a bookmarklet) is supposed to
pop a window containig a "textarea".


javascript:(
function()
{

var nd =
window.open('','','directories=yes,left=0,width=600,height=300').document;

var box = nd.createElement('textarea');

box.setAttribute('rows','15');

box.setAttribute('cols','50');

nd.body.appendChild(box);

}
)()

It works fine in FireFox. On IE, the window is popped, but without the
textarea. What could be the reason?

Appreciate any help.

--Jess
 
J

Joshie Surber

my guess (since i don't have id) is that you aren't naming the new
window. try something like

var
win=window.open('','','directories=yes,left=0,width=600,height=300');
var nd=win.document

then use your code as you have it. you might also try replacing
nd.body.appendChild with
nd.getElementsByTagName('body')[0]
because I am not sure if IE has a document.body variable, though I may
be wrong on this count too. Worth a shot though.
 
R

Randy Webb

(e-mail address removed) said the following on 10/19/2005 7:40 PM:
The following javascript code (used as a bookmarklet) is supposed to
pop a window containig a "textarea".


javascript:(
function()
{

var nd =
window.open('','','directories=yes,left=0,width=600,height=300').document;

var box = nd.createElement('textarea');

box.setAttribute('rows','15');

box.rows = '15';
box.setAttribute('cols','50');

box.cols = '50';

IE is notorious not to have support for setAttribute, access the
property directly.

All on one line of course:
javascript:(function(){var
nd=window.open('','','directories=yes,left=0,width=600,height=300').document;var
box=nd.createElement('textarea');box.rows='150';box.cols='50';nd.body.appendChild(box);})()
 
R

Randy Webb

Joshie Surber said the following on 10/19/2005 9:39 PM:
my guess (since i don't have id) is that you aren't naming the new
window. try something like

Re-read the code. It has a reference to the new window and its document.
var
win=window.open('','','directories=yes,left=0,width=600,height=300');
var nd=win.document

then use your code as you have it. you might also try replacing
nd.body.appendChild with
nd.getElementsByTagName('body')[0]

Neither will cause it to work "properly" as IE has a lack of support for
setAttribute
because I am not sure if IE has a document.body variable, though I may
be wrong on this count too.

Yes, IE has a document.body

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer: Google Users who don't quote.
Question: What's even worse?
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top