在母版页中调用jqueru脚本 [英] call jqueru script in masterpage

查看:79
本文介绍了在母版页中调用jqueru脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家
我在母版页中调用了一个jquery文件(Design.js),说design.js的位置在根目录下的JS文件夹中.我在public文件夹上有一个网页,它是从母版页继承而来的,但是在我的网页中,我的网页在public文件夹中无法访问design.js
我该如何解决这个问题.从每个地方的每个网页访问design.js

hi experts
i called a jquery file(Design.js) in master page that the place of design.js is in folder JS in root i have a webpage on folder public that it inherited from master page but in this page but my web page in folder public couldn''t access to design.js
how i must solve this problem.access to design.js from every webpage in every place

推荐答案

您好,

如果我没有记错的话,您已经将js文件作为相对URL引用了.即使从母版页放置的文件路径是正确的,在请求过程中真正发生的是,母版页中的HTML随同派生页面的html一起发送到浏览器.

因此,实际上,浏览器会尝试查找相对于当前URL(派生页面url)而不是母版页的js文件.因此,您需要更改引用,例如〜/js/design.js". 〜表示从根目录映射相对路径,因此无论子页面的位置如何,它都将解析为正确的路径.

希望对您有所帮助
Hi there,

If I am not wrong, you have referenced to the js file as a relative url. Even though the file path is correct from where the master page is placed, during a request what really happens is that, the HTML in the masterpage is just sent to the browser along with the derived page''s html.

So in reality, the browser tries to look for your js file relative to the current URL (derived page url) not the masterpage. So you need to change your reference like ''~/js/design.js''. The ''~'' means to map the relative path from the root, so regardless of the child page location, it resolves to the correct path.

Hope this helps, regards


这篇关于在母版页中调用jqueru脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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