You*_*uss 43 iframe jquery load
我想点击加载一个iframe,这是我到目前为止:
$("#frame").click(function () {
$('this').load("http://www.google.com/");
});
Run Code Online (Sandbox Code Playgroud)
它不起作用.这是完整的代码:JS Bin
Dog*_*ert 95
$("#button").click(function () {
$("#frame").attr("src", "http://www.example.com/");
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="mydiv">
<iframe id="frame" src="" width="100%" height="300">
</iframe>
</div>
<button id="button">Load</button>
Run Code Online (Sandbox Code Playgroud)
试试$(this).load("/file_name.html");
.此方法以本地文件为目标.
您还可以定位远程文件(在另一个域上),请访问:http://en.wikipedia.org/wiki/Same_origin_policy
$("#frame").click(function () {
this.src="http://www.google.com/";
});
Run Code Online (Sandbox Code Playgroud)
有时简单的JavaScript比jQuery更酷,更快;-)
小智 5
这是视图中的 Iframe:
<iframe class="img-responsive" id="ifmReport" width="1090" height="1200" >
</iframe>
Run Code Online (Sandbox Code Playgroud)
将其加载到脚本中:
$('#ifmReport').attr('src', '/ReportViewer/ReportViewer.aspx');
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
187452 次 |
最近记录: |