I tried googling how to do this but I'm not exactly sure what to call it. Basically there are a few pieces of javascript and html that I want to use across all my pages. Instead of adding these pieces of code to every single page, is there a way to add them all into one file and then use to access them? Also, if anyone has a good source to read up on this I would appreciate a link.
What I want in my sheet are my js for context menu functions:
function ShowMenu(control, e, id) {
var posx = e.clientX + 'px';
var posy = e.clientY + 'px';
var a = document.getElementById(control);
a.style.position = 'absolute';
a.style.display = 'inline';
a.style.left = posx;
a.style.top = posy;
var jqContext = '#' + control;
var view = document.getElementById("viewId");
view.href = "Chat.aspx?RecID=" + id; //Construct your URL based on parameter
}
function HideMenu(control) {
document.getElementById(control).style.display = 'none';
}
My context menu:
<div style="display:none; " id="contextMenu">
<table border="0" cellpadding="0" cellspacing="0"
style="border: thin solid #808080; cursor: default;" width="100px"
bgcolor="White">
<tr>
<td >
<a href="#" id="viewId"> View</a>
</td>
</tr>
<tr>
<td >
<a href="#" id="editId">Edit</a>
</td>
</tr>
</table>
</div>
And possibly the menu bar I have on every single page:
<!-- NAVBAR
=================== -->
<div class="navbar-wrapper">
<!-- Wrap the .navbar in .container to center it within the absolutely positioned parent. -->
<div class="container">
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. -->
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Brand</a>
<!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. -->
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<%try
{ %>
<% if ((bool)Session["userIsAuthenticated"] == false) %>
<% {%>
<li><a href="LogIn.aspx"">Log in</a></li>
<% } %>
<%else %>
<%{ %>
<li><a href="InitializePage.aspx">Log Out</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Art</a>
<ul class="dropdown-menu">
<li><a href="UploadArt.aspx">Upload Art</a></li>
<li><a href="SearchForArt.aspx">Search For Art</a></li>
</ul>
</li>
<li><a href="MeetPeople.aspx">Meet People!</a></li>
<%} %>
<%} %>
<%catch { Response.Redirect("~/InitializePage.aspx"); } %>
<li><a href="Register.aspx">Register</a></li>
<%try
{
if (((bool)Session["userIsAuthenticated"]) == true)
{%>
<li><a href="UserStats.aspx">User Information</a></li>
<%}
}
catch
{
Response.Redirect("~/InitializePage.aspx");
}%>
<li><a href="">Donate!</a></li>
</ul>
</div><!--/.nav-collapse -->
</div><!-- /.navbar-inner -->
</div><!-- /.navbar -->
</div> <!-- /.container -->
</div><!-- /.navbar-wrapper -->
Thanks