Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery-method in .NET not executing
    primarykey
    data
    text
    <p>I'm running Visual Studio 2008 and .NET 3.5</p> <p>I created a javascript method (window.unbeforeload) with javascript to give users a message when trying to exit the site. Unfortunatly, the same message is displayed every time a user clicks a link that's not redirecting outside of the site.</p> <p>Solution: to let jquery handle all link-clicks inside the site. But this isn't working.</p> <pre><code> &lt;asp:Content ID="ContentHead" ContentPlaceHolderID="head" runat="server"&gt; &lt;script type="text/javascript" src="HTML/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).live('click',function() { $("a").click(function() { alert("Hello world!"); }); }); &lt;/script&gt; </code></pre> <p>//lots of other functions</p> <pre><code> &lt;script type="text/javascript"&gt; window.onbeforeunload = function() { return "REALLY?" } &lt;/script&gt; &lt;/asp:Content&gt; </code></pre> <p>Here I tried making any click on a link inside the site create an alert, to no success.</p> <p><strong>How to go about making Jquery work in my application?</strong> </p> <p>Sideinfo: I have verified that the jquery file exists at HTML/jquery.js but despite this, Visual Studio 2008 issues a warning of file not found. Another .aspx page with the exact same path to the jquery file does not issue this warning. </p> <p>UPDATE:</p> <pre><code> &lt;%@ Page Language="C#" MasterPageFile="~/Manage/ConceptManager.Master" AutoEventWireup="true" CodeBehind="ConceptManager.aspx.cs" Inherits="DynamicForm.Manage.ConceptManagerPage" %&gt; &lt;%@ Register src="Controls/Element_MetadataEditor_FieldNode.ascx" tagname="Element_MetadataEditor_FieldNode" tagprefix="uc1" %&gt; &lt;%@ Register src="Controls/Element_MetadataEditor_TemplateNode.ascx" tagname="Element_MetadataEditor_TemplateNode" tagprefix="uc3" %&gt; &lt;%@ Register src="Controls/CategoryAttributes.ascx" tagname="CategoryAttributes" tagprefix="usercontrol" %&gt; &lt;%@ Register Src="Controls/ConfirmDialog.ascx" TagName="DeleteConfirmDialog" TagPrefix="usercontrol" %&gt; &lt;%@ Register Src="Controls/ConfirmDialog.ascx" TagName="ConfirmDialog" TagPrefix="usercontrol" %&gt; &lt;%@ Register src="Controls/AddReferenceDialog.ascx" TagName="AddReferenceDialog" TagPrefix="usercontrol" %&gt; &lt;%@ Register src="Controls/AddIncludeDialog.ascx" TagName="AddIncludeDialog" TagPrefix="usercontrol" %&gt; &lt;%@ Register Assembly="ExtExtenders" Namespace="ExtExtenders" TagPrefix="ExtExt" %&gt; &lt;asp:Content ID="ContentHead" ContentPlaceHolderID="head" runat="server"&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { var mydomain = "mysite.com"; var leavemessage = "Are you sure you wish to leave?"; var filterMySitefunction = function(index) { return $(this).attr("href").indexOf(mydomain) &gt; -1; } var filterOtherSitefunction = function(index) { return $(this).attr("href").indexOf(mydomain) == -1; } $("a").filter(filterMySitefunction).click(function() { window.onbeforeunload = function() { }; }); $("a").filter(filterOtherSitefunction).click(function() { window.onbeforeunload = function() { return leavemessage; }; }); }); &lt;/script&gt; &lt;/asp:Content&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload