/    Sign up×
Community /Pin to ProfileBookmark

what is this code doing?????

[code=php]function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf(“?”))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterAug 19.2005 — Giving you an error because you left out the final [b]}[/b] after the [b]return x;[/b] statement. ?

It's basically a document.getElementById function and document.getElementsByName function in one that is very specific as to which frame/window it is searching for what. In the end, it returns the element found.

To call the function [b]MM_findObj(n, d)[/b] the [b]n[/b] is a string either the ID of a tag element or the NAME of a tag element within a form. The [b]d[/b] part is optional as to the document to search for the tags.
×

Success!

Help @mikeyzc 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.16,
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,
)...