2017-04-07 56 views
0

我有jquery行,允許我打開.window並訪問其中一個HTML文件,它的效果很好。請參閱示例代碼。如何添加iframe

<?php if (isset($_SESSION['currentfile'])) { ?> 
$("#sourcepreviewout").click(function() { 
window.open("<?php $dir = "template/" . trim(file_get_contents("admin/template.txt")) . "/result/"; 
echo $dir . $_SESSION['currentfile']; 
?>", '_blank'); 
}); 
<?php } ?> 
}); 

我想在window.open添加,......我怎麼可以編寫代碼來與200像素的大小由200像素的窗口打開添加<Iframe>並顯示內的HTML文件!

回答

0

你不需要這個jQuery。你可以用Javascript來做他非常容易的事情。

// Change "src" of iframe with your html Link 
var iframe = "<iframe src='https://wiki.selfhtml.org/wiki/JavaScript/Window/open' width='200' height='200'></iframe>"; 

var openWindow = window.open("", "Opened Window", "width=500,height=500,location=no"); 

openWindow.document.write(iframe); 

例子:https://jsfiddle.net/06hpd7p7/1/

我想,這就是全部,你需要什麼