How can i get to the textarea in Gmail Draft.

H

HopfZ

I am trying to make a bookmarklet to enlarge textarea in Gmail. But I
can't get to the textarea.
When you are composing a message in Gmail, the page has two frames. the
first frame has name "main". That frame contains a textarea named
"msgbody" in which you compose messages.

I have tried with Firebug getElementsByTagName and getElementsByName
but all fails.
self.main.document.getElementsByTagName('textarea') returns empty list.
self.main.document.getElementsByName('msgbody') also returns empty
list.
I suspect that it is because the textarea is buried deep in the DOM
tree.
The dom path from the main frame to the textarea is:
/html/body/table/tbody/tr[2]/td[2]/form/table/tbody/tr[5]/td/div[3]/table/tbody/tr[2]/td[2]/textarea

However the dom path from the main frame to the first div element is
/html/body/div
and self.main.document.getElementsByTagName('div') returns a nonempty
list.
 
M

Martin Honnen

HopfZ wrote:

I have tried with Firebug getElementsByTagName and getElementsByName
but all fails.
self.main.document.getElementsByTagName('textarea') returns empty list.

Then what you think is a textarea is not one or that textarea is in a
different document.
 
H

HopfZ

Martin said:
HopfZ wrote:



Then what you think is a textarea is not one or that textarea is in a
different document.


Thank you for your answer.
I found that there was an iframe between the main frame and the
textarea.
The name of the iframe is v1 or v2 depending on situations.

// get to the composing textarea in Gmail. (new message or a saved
draft)
var textArea1 = self.main.v1.document.getElementById('ta_0');
var textArea2 = self.main.v2.document.getElementById('ta_compose');
var theComposingTextArea = textArea1 ? textArea1 : textArea2;
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top