/    Sign up×
Community /Pin to ProfileBookmark

Weird thing about onclick().

[FONT=Fixedsys]

[code=html]<body onload=d.b.select()>
<form name=d><p>Word:
<br><input name=b accesskey=w></p>
<p><input type=button onclick=”if (window.confirm(‘Submit without a category?’)) d.submit();” value=Add>
*<input type=button onclick=all(”) value=Add&nbsp;all></p><p><input type=text name=e>*
<input type=button value=SAT accesskey=a onclick=d.e.disabled=false;go(‘ ‘)>
<input type=button value=HEN accesskey=s onclick=d.e.disabled=false;go(‘/’)>
<input type=button value=Dictionary accesskey=d onclick=d.e.disabled=false;go(”)></p></form></body><script>
function go(a)
{
d.e.value=a;
d.submit();
}
function add(a, b, c)
{
b.onclick=function(){
top.location.replace(‘?b=’ + a + ‘&e=’ + c);
};
b.value=b.value.toUpperCase()
b.setAttribute(‘accessKey’,”)
window.open(‘?add=’ + a);
d.b.focus();
}
function all(c)
{
b=document.getElementsByTagName(‘input’);
for (a=0; a<b.length – 8; a++) alert(b[a].name);//add(b[a].name, b[a], c);
}
</script>[/code]

There is much more code, but this just includes all of the pertinent one. When I type in “javascript:alert(d.elements[2].onclick)” I get

[CODE]function anonymous()
{
all(”)
}[/CODE]

. However, when I type in “javascript:d.elements[2].onclick()” it gives “Object doesn’t support this action” error (at the starred line). If I type in javascript:all(”), it executes it without a problem. As well, when I type in “javascript:d.elements[2].onclick=function(){all(”)}”, the following happens:
when I type in “javascript:alert(d.elements[2].onclick)” I get

[CODE]function(){all(”)}[/CODE]

, and when I type in “javascript:d.elements[2].onclick()”, it runs normally. Could someone please help?[/FONT]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@DragonauthorSep 09.2006 — [FONT=Fixedsys]Does no one know the answer?[/FONT]
Copy linkTweet thisAlerts:
@KorSep 09.2006 — which answer to which question?

When you try to alert an event (like alert(d.elements[2].onclick)) , if the event triggers a function, you will receive in alert that function. What is so weird? In fact, which is your problem?
Copy linkTweet thisAlerts:
@DragonauthorSep 12.2006 — [FONT=Fixedsys]Nevermind; someone else answered it... But anyways, the all function did not run upon its being loaded by the page. Unless I manually defined it as the exact same thing it was defined before, and then it did run. The problem was that it was called all, and that's a reserved keyword.[/FONT]
×

Success!

Help @Dragon 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.22,
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,
)...