/    Sign up×
Community /Pin to ProfileBookmark

Help with indexOf()

Please help me with this code. When I try to run it nothing appears

[CODE]<script type=”text/javascript”>
var local=document.loaction;
if (local.indexOf(“.html”)=! -1)
{
document.write(“This page has a .html extension!”);
}
else
{
document.write(“Other extension”);
}
</script>[/CODE]

Thanks!!

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERJun 27.2008 — Haven't tested it but I think:

if (local.indexOf(".html")=! -1)

needs to be

if (local.indexOf(".html") != -1)
Copy linkTweet thisAlerts:
@Logic_AliJun 27.2008 — [SIZE=2]Please help me with this code. When I try to run it nothing appears[/quote]I'm sure something appears in the error console.



&lt;script type="text/javascript"&gt;</CODE>
**var local=document.<B>[B]<COLOR color="#ff0000">[COLOR=#ff0000]loaction[/COLOR]</COLOR>[/B]</B>;
[/quote]
Typo - and [I]location [/I]is a property of [I]window [/I]and it is not a string. Use [I]location.href[/I].[/SIZE]
Copy linkTweet thisAlerts:
@webcoder13authorJun 27.2008 — Thanks!!
×

Success!

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