用这个试试:
var iphoneUrl = 'myScheme://{0}?{1}'
function callNativeFunction(functionName) {
var args = Array.prototype.slice.call(arguments, 1);
if (window.andriod) {
andriod[functionName].apply(this, args);
}
else {
var params = '';
for (var i = 0, len = args.length; i < len; i++) {
params += 'param' + (i + 1) + '=' + encodeURIComponent(args[i]) + '&';
}
params = params.slice(0, -1);// remove last &
window.location = iphoneUrl.format(functionName, params);
}
}
callNativeFunction('functionName', 'param1');
String.Format:
String.prototype.format = function () {
var args = arguments;
return this.replace(/{(\d+)}/g, function (match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};