I need to get the id from the url. Therefore, if the URL looks something like this: http: // localhost: 17241 / Chart.aspx? Id = 11
I should get number 11 as output. But each site has a different identifier. And after that I will set the z-index to this.
I already tried to write something
$.urlParam = function (name) { var patt1 = new RegExp('[^17241]').exec(window.location.href); return result[1] || 0; document.getElementById("link").innerHTML = result;}
But this does not work at all. Does anyone know what to do?
So now it should change z-index:
var url = window.location.href; var params = url.split('?'); var id = params[1].split('=')[1]; //params[1] will contain everything after ? console.log(id); if(id == 11) { $("#one").each(function() { $(this).css("z-index", 0); }); } else if(id == 31) { $("#four").each(function() { $(this).css("z-index", 0); }); }
And it should change the z-index of divs
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server"> <div class="contentwidth" id="chartdiv"> <asp:Label ID="lblStatus" runat="server"></asp:Label> <div id="one" style="position: absolute; top: 0; left: 0; height: 100%; width: 100%;"> <asp:Literal ID="ltrRenderChart" runat="server"></asp:Literal> </div> <div id="two" style="position: absolute; top: 0; left: 50%; height: 100%; width: 100%; z-index:-1"> <asp:Literal ID="ltrRenderChart2" runat="server"></asp:Literal> </div> <div id="three" style="position: absolute; top: 50%; left: 0; height: 100%; width: 100%; z-index:-1"> <asp:Literal ID="ltrRenderChart3" runat="server"></asp:Literal> </div> <div id="four" style="position: absolute; top: 50%; left: 50%; height: 100%; width: 100%; z-index:-1 "> <asp:Literal ID="ltrRenderChart4" runat="server"></asp:Literal> </div> </div>
thanks
source share