简体   繁体   中英

how to call javascript function from another domain?

working with a asp.net 3.5 solution with various projects. I have a javascript file called MyScript which sits in WebprojectA. What I would like to do is refer to this scriptfile in my WebProjectB? example some code in aspx page in WebProjectB:

//this script sits in WebProjectA:
    <script src="../Scripts/Myscript.js" type="text/javascript"></script>

Is there anything wrong with doing it like this?

//this script sits in WebProjectB:
    <script src="http://www.webprojecta.com/Scripts/Myscript.js" type="text/javascript"></script>

Your will have to share a common directory structure or reference via a site url. The best approach is to use a CDN.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM