/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] JavaScript Popup Problems…

What is wrong with this code?

[CODE]function reportit_createobj() {
var popupobj = document.createElement(“object”);
popupobj.setAttribute(“id”, “reportit_popup”);
popupobj.setAttribute(“type”, “text/html”);
popupobj.setAttribute(“style”, “display: none; position: fixed; top: 100px; left: 100px; background: #ccc; height: 100px; width: 400px; padding: 5px; border: 1px solid #000;”);
popupobj.setAttribute(“data”, “script.php?id=0”);
popupobj.innerHTML = “<p>ReportIt! Interface</p>”;
document.body.appendChild(popupobj);
}

window.onload = function() { reportit_createobj(); };

function reportit_popup(id) {
var popup = document.getElementById(“reportit_popup”);

if(popup.style.display == “block”) {
popup.style.display = “none”;
} else {
popup.setAttribute(“data”, “script.php?id=” + id);
popup.style.display = “block”;
}
}[/CODE]

This is how I use it:

[CODE]<a href=”javascript:void(0)” onClick=”reportit_popup(1)”>popup</a>[/CODE]

It seems like it should work. It’s fairly straightforward. But it’s not working. It doesn’t do anything when I click on the link. Plus, the Web Developer Toolbar in Firefox gives me this error:

[CODE]Error: uncaught exception: [Exception… “Component is not available” nsresult: “0x80040111 (NS_ERROR_NOT_AVAILABLE)” location: “JS frame :: http://localhost/2008/04/hello-world/ :: onclick :: line 1” data: no][/CODE]

Any help would be super! ?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 07.2008 — Scope: id value the same as function name, change one of these.
Copy linkTweet thisAlerts:
@JickauthorApr 07.2008 — Well, that's what I get for being a JS n00b. :p

It works perfectly now. Thanks! ?
×

Success!

Help @Jick 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 6.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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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