Friday, February 22, 2013

JQUERY GET CURRENT PAGE URL


$(document).ready(function() { &nbsp; &nbsp; //jquery &nbsp; &nbsp; $(location).attr('href'); &nbsp; &nbsp; //pure javascript &nbsp; &nbsp; var pathname = window.location.pathname; &nbsp; &nbsp; &nbsp; &nbsp; // to show it in an alert window &nbsp; &nbsp; alert(window.location); });<br />Javascript Functionfunction getAbsolutePath() { &nbsp; &nbsp; var loc = window.location; &nbsp; &nbsp; var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1); &nbsp; &nbsp; return loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length)); }

No comments:

Post a Comment