/    Sign up×
Community /Pin to ProfileBookmark

Using Javascript with gmail

I have tried a simple thing in Firebug:

[code]
var te = document.getElementsByName(‘subject’);

for(var i in te) {
document.write(te[i]);
}[/code]

to access objects.

And then it simply prints:

[code]
0function item() { [native code] }function namedItem() { [native code] }[/code]

I want to be able to alert the content of the subject line in Gmail.but am unable to get anything to work. Could someone please guide me in this regard?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ZeroKilledOct 22.2008 — the initial code will print some properties and/or method of a NodeList because that is what getElementByName return, even if there is a single item in the document. however, what you want is the found element. then you would do:
<i>
</i>for(var i in te[0]){
document.write(te[0][i]);
}

that will give you the properties/method of the first found element if any.
Copy linkTweet thisAlerts:
@LegendauthorOct 22.2008 — Hi,

Thank You... But the problem is, it doesn't seem to print anything at all... I have tried accessing the element as document.getElementById(':mv") but still with no luck... ?
×

Success!

Help @Legend spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...