Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Thursday, December 19, 2013

Change url without reloading application using javascript

Hello All,

I worked on application which need to change url after loading page because I don’t want to show user to full url.

I can do this by window.location but it will reload our application but I don’t want this also.

Here small code snipt which will done this job.

<script>

        var clean_uri = location.protocol + "//" + location.host + location.pathname;
        window.history.replaceState({}, document.title, clean_uri);

</script>

Tuesday, September 18, 2012

How to get CSS class property value in javascirpt


Hello all,
Recently I working with javascript and css and for show and hide some element on base of css class's value.
I try  document.getElementById('elementId').style.display but it's failed because it's work only with inline style.

so I got below javascript code for get value of display property of css class in javascript.

   var elementObj = document.getElementById('elementId');
   var displayType= window.getComputedStyle(elementObj, null).getPropertyValue('display');
    alert(displayType);

displayType is the one of the value from inline,none or block.