您的位置 首页 java

js日常使用(一)

js调用安卓ios方法:

var param = { funName: “fullScreen”, url: arr, playProgress: playProgress };

if (/( iPhone | iPad |iPod|iOS)/i.test(navigator.userAgent)) {

this.videoPause();

window.webkit.messageHandlers.jsCallAction.postMessage(param);

}

else if (/( Linux |Android)/i.test(navigator.userAgent)) {

this.videoPause();

window.android.callJavaMethod(JSON.stringify(param));

}

js post 提交参数并跳转:

function toPost() {

var parames = new Array();

parames.push({ name: “res”, value: “cR2EwqGK44Xsos0uzwh55pxU5cet8WKdd6T0w”});

Post(“#34;, parames);

return false;

}

/*

*功能: 模拟form表单的提交

*参数: URL 跳转地址 PARAMTERS 参数

*/

function Post(URL, PARAMTERS) {

//创建form表单

var temp_form = document.createElement(“form”);

temp_form.action = URL;

//如需打开新窗口,form的target属性要设置为’_blank’

temp_form.target = “_self”;

temp_form.method = “post”;

temp_form.style.display = “none”;

//添加参数

for (var item in PARAMTERS) {

var opt = document.createElement(“textarea”);

opt.name = PARAMTERS[item].name;

opt.value = PARAMTERS[item].value;

temp_form.appendChild(opt);

}

document.body.appendChild(temp_form);

//提交数据

temp_form.submit();

}

js延时返回处理:

setTimeout(function () { window.dialogReturn(1); CloseDlg(); }, 2000);

全局替换:

remark.replace(/[$]/g, “\n”)

文章来源:智云一二三科技

文章标题:js日常使用(一)

文章地址:https://www.zhihuclub.com/186310.shtml

关于作者: 智云科技

热门文章

网站地图