Reputation: 1
I'm trying to load a custom javascript for cloudzoom on desktops and a other one for touch devices.
In my i have this piece of code:
if ("ontouchstart" in document.documentElement){
// It's a touch screen device.
$.getScript('/js/cloud-zoom.1.0.2.min.js'),
$(function() {
alert('iPad Load was performed.');
});
}
else {
$.getScript('/js/cloud-zoom.1.0.2.custom.js'),
$(function() {
alert('Custom Load was performed.');
});
}
This works fine. But when i remove the alert the script will not load... I don't get a error in the console of firefox either. How can i make it work without alerting something.
Upvotes: 0
Views: 789
Reputation: 887807
You have a syntax error.
You wrote
$.getScript(...),
$(function() { });
The ,
is invalid and should not be there.
If you want to pass a script callback, write
$.getScript("...", function() { ... });
Upvotes: 4