Modify the URL without reloading the page Is there any way I can modify the URL of the current page without reloading the page? I would like to access the portion before the # hash if possible. I only need to change the portion after the domain, so its not like I'm violating cross-domain policies. window.location.href = "www.mysite.com/page2.php"; // sadly this reloads Answer: This can now be done in Chrome, Safari, FF4+, and IE10pp4+! See this question's answer for more info: Updating address bar with new URL without
undefined
Change an element's class with JavaScript How can I change a class of an HTML element in response to an onClick event using JavaScript? Answer: Adding and Removing Classes, with simple cross-browser JavaScript The standard JavaScript way to select an element is using document.getElementById("Id"), which is what the following examples use - you can of course obtain elements in other ways, and in the right situation may simply use this instead - however, going into detail on this is beyond the scope of the answer. To change all
undefined
Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”? The following are two methods of building a link that has the sole purpose of running JavaScript code. Which is better, in terms of functionality, page load speed, validation purposes, etc.? function myJsFunc() { alert("myJsFunc"); } <a href="#" onclick="myJsFunc();">Run JavaScript Code</a> or function myJsFunc() { alert("myJsFunc"); } <a href="javascript:void(0)" onclick="myJsFunc();">Run JavaScript Code</a> Most relevant Solution : I use javascript:void(0). Three reasons. Encouraging the use of # amongst a team of developers inevitably leads to
undefined
Make div 100% height of browser window I have a layout with two columns - a left div and a right div. The right div has a grey background-color, and I need it to expand vertically depending on the height of the user's browser window. Right now the background-color ends at the last piece of content in that div. I've tried height:100%, min-height:100%; etc. Best Answer: There are a couple of relatively new CSS3 measurement units called: Viewport-Percentage (or Viewport-Relative) Lengths What are Viewport-Percentage Lengths? From the linked W3 Candidate Recommendation above: