1

I have to find current url and if it is equal to "http://localhost/mysite" then I need to put below code.

Example (pseudocode):

If(FindCurrentURL.ContainsString("http://localhost/mysite")){
  .ms-quickLaunch {  display: none; }
}

How to find URL and that contains above URL?

Marcel Korpel
  • 21,536
  • 6
  • 60
  • 80
James123
  • 11,184
  • 66
  • 189
  • 343
  • possible duplicate of [How to get the current URL in jQuery?](http://stackoverflow.com/questions/406192/how-to-get-the-current-url-in-jquery) – miku Sep 04 '10 at 22:58

3 Answers3

2

The window.location.href property will contain your current URL, which you can then test against in your if statement:

if(window.location.href.indexOf('http://localhost/mysite') >= 0){
    // do something fancy
}
Pat
  • 25,237
  • 6
  • 71
  • 68
2

The full current URL can be found in

window.location.href

the second part of your question is not as easy to implement as it seems. There are several ways to modify a CSS class during runtime, but none of them is really convenient and simple.

Consider targeting whatever element you want to hide using an ID and document.getElementById().

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
0

There is no need to change the CSS rule. Just select all the elements of that class and hide them via JavaScript.

For example, in jQuery:

$(".ms-quickLaunch").hide();
Šime Vidas
  • 182,163
  • 62
  • 281
  • 385