在asp.net中使用javascript代码时遇到的问题 [英] Problem facing while using javascript code in asp.net

查看:51
本文介绍了在asp.net中使用javascript代码时遇到的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我在页面中使用的代码。



Here is the code i used in my page.

<script type="text/javascript">

window.onbeforeunload = function () {
    if (_clickedAnchor) {
        _clickedAnchor = false;
        return "Out Put Message";
    }
}

_clickedAnchor = false;

jQuery(document).ready(function () {
    jQuery("a").click(function () {
        _clickedAnchor = true;
    });
});

</script>







错误:-JavaScript运行时错误:'jQuery'未定义




Error:-JavaScript runtime error: 'jQuery' is undefined

推荐答案

因为它读取=你没有jQuery。

首先使用NuGet为你的项目添加jQuery,而不是使用< script>< / script> 标签...



添加对jQuery包的引用...

1.右键单击您的项目

2.选择管理NuGetPackage

3.在线选择

4.搜索jQuery

5.点击安装



将jQuery添加到你的页面......

在<$ c你的页面的$ c>< head> 添加这样的行:

As it reads = you have no jQuery.
First add jQuery to your project using NuGet, than add jQuery to your page using <script></script> tag...

Add reference to jQuery package...
1. right click your project
2. select Manage NuGetPackage
3. select online
4. search for jQuery
5. hit install

Add jQuery to your page...
In the <head> of your page add line like this:
<script src="/js/jquery-1.7.1.js" type="text/javascript"></script>



确切路径和版本可以不同......


Exact path and version can be different...


这篇关于在asp.net中使用javascript代码时遇到的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆