<script type="text/javascript">
// iframe加载完毕
window.pageLoad = function () {
// console.warn('iframe加载完毕');
};
//当url更改时会继续进入
window.onload = function () {
var b_iframe = parent.parent.document.getElementById("iframe1");
var hash_url = window.location.hash.split("#");
var hash_height = hash_url[1] + "px";
b_iframe.style.height = hash_height;
}
</script>
<script type="text/javascript">
function get_url() { //定义函数
var url = window.location.href; //获取当前页面的url
var pattern = /(\w+)=(\w+)/ig; //定义正则表达式
var parames = {}; //定义数组
url.replace(pattern, function (a, b, c) {
parames[b] = c;
});
var objid = parames['objid']; //返回这个数组.
document.getElementById('iframe1').src += '?objid=' + objid;
}
get_url();
function onMessage(jqEvent) {
console.warn('高度---', jqEvent.originalEvent.data.iframe);
if (jqEvent.originalEvent.data.iframe) {
var iframeContentHeight = jqEvent.originalEvent.data.iframe;
$('iframe').height(iframeContentHeight + 100);
}
}
$(window).on('message.socialPanel', onMessage);
</script>
网友评论