var ClientUrl = Xrm.Page.context.getClientUrl();
var id = Xrm.Page.data.entity.getId().replace("{", "").replace("}", "");
var openhtlm = ClientUrl + "/WebResources/new_qccSearch?id=" + id;
var iWidth = window.screen.availWidth * 0.84;
var iHeight = window.screen.availHeight * 0.74;
var iTop = (window.screen.height - 30 - iHeight) / 2; //获得窗口的垂直位置;
var iLeft = (window.screen.width - 10 - iWidth) / 2; //获得窗口的水平位置;
window.open(openhtlm, null, 'height=' + iHeight + ',innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
//自定义页面获取值
var id = getQueryVariable("id");
///
//获取url上的传参
//variable=参数名
//
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
return (false);
}
var parameters = {};
parameters.entityid = Xrm.Page.data.entity.getId();
parameters.entityname = Xrm.Page.data.entity.getEntityName();
parameters.entityurl = "";//url
var pageInputs = {
pageType: "webresource",
webresourceName: "xxx.html",
data: JSON.stringify(parameters)
};
var navigationOptions = {
target: 2,
width: Xrm.Page.context.client.getClient() === "Mobile" ? 200 : 500, // value specified in pixel
height: 200, // value specified in pixel
position: 1
};
Xrm.Navigation.navigateTo(pageInputs, navigationOptions).then(
function success() {
// Run code on success
},
function error() {
// Handle errors
}
)
//自定义页面接收值
<script>
var _this = this;
var Wourl = decodeURIComponent(location.search);
if (Wourl.indexOf("?") != -1) {
var str = Wourl.substr(1)
strs = str.split("&");
var key = new Array(strs.length);
var value = new Array(strs.length);
for (i = 0; i < strs.length; i++) {
key[i] = strs[i].split("=")[0]
value[i] = unescape(strs[i].split("=")[1]);
}
}
var data = JSON.parse(value);
let entityid = data.entityid
let entityname = data.entityname
let entityurl = data.entityurl
</script>