我正在使用Iframe Resizer,但我的代码无法跨域工作。当两个域相同时它工作正常。你能帮我吗?这很奇怪,因为 iframe 肯定加载了 iFrameResizer.contentWindow.js 并且我使用 checkOrigin: false 所以它应该允许跨域...
以下是加载具有 iframe 的父页面时在控制台中出现的错误:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://jacobjohnson.net') does not match the recipient window's origin ('http://designtesting.cfs.local').
iframeResizer.min.js:8 [iFrameSizer][Host page: display_frame] No response from iFrame. Check iFrameResizer.contentWindow.js has been loaded in iFrame
<div class="panel panel-default" id="iframePanel">
<div class="panel-body" style="padding:0px;">
<iframe id="display_frame" name="display_frame" class="frame" src="http://jacobjohnson.net/iframetest.html" allowfullscreen></iframe>
</div>
</div>
<script>
jQuery('#display_frame').iFrameResize( [{log:true, checkOrigin: false}] );
var frameHeight = 3905; // $('#display_frame').height();
var newHeight = frameHeight / …Run Code Online (Sandbox Code Playgroud) 我基于 这个 拖放示例工作:
我想拖一个组。我将两个矩形放在一个组中,现在想要拖放整个组,在我的代码中拖放适用于单个矩形但不适用于组。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"> </script>
<title>Drag And Drop</title>
</head>
<body>
<div id="viz"></div>
<script type="text/javascript">
var vizSVG = d3.select("#viz")
.append("svg")
.attr("width", 400)
.attr("height", 300);
var group =d3.select("svg")
.append("g")
.attr("id","group1")
.attr("x",50)
.attr("y", 140)
//.attr("fill", "yellow")
// .call(d3.behavior.drag().on("drag", move));
group.append("rect")
.attr("id", "bluerect")
.attr("x", 50)
.attr("y", 140)
.attr("width", 50)
.attr("height", 50)
.attr("stroke", "red")
.attr("fill", "blue")
.attr("opacity","0.5")
.call(d3.behavior.drag().on("drag", move));
group.append("rect")
.attr("id", "redrect")
.attr("x", 110)
.attr("y", 140)
.attr("width", 50)
.attr("height", 50)
.attr("stroke", "blue")
.attr("fill", "red")
.call(d3.behavior.drag().on("drag", move));
function …Run Code Online (Sandbox Code Playgroud)