问题
I have used winstore-jscompat.js for js fix. below code generate sub categories. But it doesnt call parseSubCategory function.
$.each(category.sub_categories, function(index2, subcategory) {
var subCatName = subcategory.name;
$("#test-listview" + index).append('<li><a onclick=\"parseSubCategory(' + subcategory.id + ',\'' + subCatName + '\');\" href="#product_List">' + subcategory.name + '</a></li>');
});
Edit:
This is working fine on ios and android but not in windows mobile phone
回答1:
Issue happened because of pulling in potentially unsafe content from an external sources. We can modify jquery source and ignore this. I have found the solutions here.
https://www.incloud.de/2012/08/windows-8-using-jquery-for-app-development/
It works for me.
回答2:
Customize the content security policy in the meta tag:
http-equiv="Content-Security-Policy"
As needed. Add unsafe-inline to default-src
to enable inline JavaScript.
For details, see http://go.microsoft.com/fwlink/?LinkID=617521
来源:https://stackoverflow.com/questions/33735325/a-href-onclick-not-working-in-windows-phone-cordova-app