0

I am using one JavaScript file for multiple HTML files, but I don't want a certain part of the JavaScript file to be used for one of the HTML files. How do I check which HTML file is being used?

1
  • window.location - welcome to SO. Please visit help center to see how to ask questions Commented Jan 29, 2015 at 5:49

3 Answers 3

1

you can use window.location to get the url and parse the result and handle that case.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use window.location to get the current URL.

But, really, I think a better approach would be to have some argument or setting to activate or disable functionality. That would give you more flexibility in the long run.

Comments

0

One easy way is to pass parameters to the javascript. Look at this answer
you can also use globals, but parameters are cleaner and safer.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.