By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

textarea in a popped window

P: n/a
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=60 0,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

Oct 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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,widt h=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.

Oct 20 '05 #2

P: n/a
je******@gmail.com 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=60 0,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';bo x.cols='50';nd.body.appendChild(box);})()

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 20 '05 #3

P: n/a
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,widt h=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?
Oct 20 '05 #4

P: n/a
McA
> var box = nd.createElement('textarea');
box.setAttribute('rows','15');
box.setAttribute('cols','50');
nd.body.appendChild(box);


You must create textarea inside of form element:

window.onload=function(){

var nd =
window.open('','','directories=yes,left=0,width=60 0,height=300').document;
var frm = nd.createElement('form');
var box = nd.createElement('textarea');

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

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

frmEl=nd.body.appendChild(frm);
frmEl.appendChild(box);

}
Oct 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.