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?

eltigre
  • 223
  • 4
  • 10

3 Answers3

1

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

eyegropram
  • 672
  • 4
  • 11
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.

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
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.

Community
  • 1
  • 1
Zig Mandel
  • 19,571
  • 5
  • 26
  • 36