/    Sign up×
Community /Pin to ProfileBookmark

executing another function within js

So I have a something that looks like this:

[COLOR=firebrick]<script type=”text/JavaScript”>[/COLOR]
<!–
[COLOR=blue]if (window.name!=’body’)[/COLOR]
[COLOR=blue] top.location.replace(‘some.htm?another.htm~target’);[/COLOR]
Here I would like to execute a function i.e: swap_pic()
//–>
[COLOR=firebrick]</script>[/COLOR]

Few points: That js is only a part of a larger one, split in two docs so It shouldent make to much sence here on it own.

There are ofcourse more functions in the script section, i just put in the essentials

How do I get it to execute the other function within that little js.

Thanks,

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@ExuroDec 23.2004 — When placing multiple lines of code within an IF statement you need to surround your code block with curly braces {}. It's good programming practice to just [i]always[/i] include the curly braces, that way you can avoid bugs if you accidently add more than one line of code for the IF and forget to add in the {}s. But, this is scripting and sometimes its better to be concise since all the code has to be downloaded to the client, so you can leave them out if you like them that way for single lines of code. Anyway, here's the altered version:
[code=php]<script type="text/javascript">
<!--
if (window.name!='body') {
top.location.replace('some.htm?another.htm~target');
swap_pic();
}
//-->
</script>[/code]

Note that I changed the [FONT=courier new]type[/FONT] to "text/javascript" (no capital letters). This is a meta-data type so I think it's probably best to leave it in all lowercase...
×

Success!

Help @aeetes 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.19,
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,
)...