/    Sign up×
Community /Pin to ProfileBookmark

Please Help. Javascript

Hi,

I am have a bit of a problem with some javascript. I want to make a button that when it’s clicked a javascript prompt displays asking for your website address, when you enter it and click ok i want it to open a new window and verify that the site entered in the prompt has a div called “bla” and if so redirect to a “div Bla exists/doesn’t exist on your site” page.

at the moment i have

[CODE]function checklink(){
var usersite = prompt(“Where is the page the link is displayed?”, “http://”);
myWin = open(usersite, “myWin”,
“width=400,height=300,status=no,toolbar=no,menubar=no”);

if (!.document.getElementById(‘xsrefx’)) return
alert(“Error: ‘xsrefx’ Link Not Found”);
myWin.document.close();
}[/CODE]

but all i get is that the div doesn’t exist even when it does.

Can anyone help me please (i would like to stick to using javascript if possible)

Thank You In Advance

D85

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@milan1980Oct 03.2009 — Hi,

Most likely the DOM is not built yet by the time you run that check. Make sure the DOM is ready before checking. In jQuery it is really easy to check for that using the ready() function.

Hope this helps.
Copy linkTweet thisAlerts:
@D85authorOct 05.2009 — Sorry to be a pain but is there any chance of an example in jQuery that may work i am not having much luck.

T.I.A

D85
×

Success!

Help @D85 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.25,
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,
)...