/    Sign up×
Community /Pin to ProfileBookmark

Wait until element exists?

I’m working on a Greasemonkey script to insert a random signature into Google Groups postings. It half works…inserting the signature for new threads works great. But, with replies, the reply box pops up inline with the thread. This is where my problem comes in. The element I need to insert the text in is called cmp_body, but that element does not exist until the user clicks on the Reply button. So basically, I need the script to wait until that particular element exists, then insert the extra text into it. Here’s a link to what I’ve got so far:

[URL=”http://userscripts.org/scripts/show/8226″]http://userscripts.org/scripts/show/8226
[/URL]

The original idea was to use an onclick event handler, and that worked nicely, only problem being every time there was an additional click anywhere in the page, the signature would get inserted again. The do while loop I’ve got in there now isn’t doing anything. Anyone got an idea?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@ironcladlouauthorFeb 20.2008 — Anybody? Bueller?
Copy linkTweet thisAlerts:
@fpmarinFeb 22.2008 — How about window.onload ?
Copy linkTweet thisAlerts:
@felgallFeb 22.2008 — Perhaps http://javascript.about.com/library/blfastdom.htm may give you some ideas.
×

Success!

Help @ironcladlou 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.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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