Reputation: 9391
I have a external JS function defined below held within test.js
function InvokeSupport(ID, TimeStamp, Hash) {
var sUrl = '<%= System.Configuration.ConfigurationManager.AppSettings["URL"] %>' + "?uid=" + ID + "&t=" + TimeStamp + "&hash=" + Hash;
window.open(sUrl, "Support", null, false);
}
On my asp.net page I have the following.
<script type="text/javascript" src="../../../scripts/test.js"></script>
<div class="User">
<span class="UserName"><button type="submit" title="Help!" onclick="InvokeSupport()" class="Class1"></button> </span>
</div>
THE PROBLEM
The InvokeSupport function is coming back as undefined and fails to work unless I place the function on the ASP.net page where it works. The link to the javascript file is right as I have other files in the same repository working fine.
Any idea what Im doing wrong?
Upvotes: 0
Views: 1351
Reputation: 12213
This should work.
function InvokeSupport(url, ID, TimeStamp, Hash) {
var sUrl = url + "?uid=" + ID + "&t=" + TimeStamp + "&hash=" + Hash;
window.open(sUrl, "Support", null, false);
}
<script type="text/javascript" src="../../../scripts/test.js"></script>
<div class="User">
<span class="UserName"><button type="submit" title="Help!" onclick="InvokeSupport('<%= System.Configuration.ConfigurationManager.AppSettings["URL"] %>',1,2,3)" class="Class1"></button> </span>
</div>
Upvotes: 0
Reputation: 1265
Why are you using ASP.NET script tags in external js file?
Pass the data from configuration as and additional parameter to javascript function.
Also, you can use Firebug and Chrome devTools which can show you a place of error occured
Upvotes: 2