我正在PHP文件中创建表单。在表格中,我有一个链接。单击链接后,我想打开网页或PHP页面作为模式窗口。
下面是我要创建的test1.php中的表格。
<form action="test.php" name="form" METHOD="POST">
<a href="#" onclick="window.open('test.php','popup','scrollbars=1,width=620,height=620,top=50,left=200')" title="Listbox" class="toplinks1">Open Link</a>
<INPUT TYPE=SUBMIT NAME="SUBMIT" />
</form>
上面的表格有一个链接“ Open Link”,它确实在另一个窗口中打开了test.php。但是当test.php打开时,我可以访问test1.php。
我需要打开test.php作为模式窗口。
以下代码将解决您的问题,
<a href="http://wikipedia.com/" class="test">comment #1</a><br>
<a href="http://ebay.com/" class="test">comment #2</a><br>
<a href="http://ask.com/" class="test" >comment #3</a><br>
<div id="somediv" title="this is a dialog" style="display:none;">
<iframe id="thedialog" width="350" height="350"></iframe>
</div>
<script>
$(document).ready(function () {
$(".test").click(function () {
$("#thedialog").attr('src', $(this).attr("href"));
$("#somediv").dialog({
width: 400,
height: 450,
modal: true,
close: function () {
$("#thedialog").attr('src', "about:blank");
}
});
return false;
});
});
</script>
还要检查JSFiddle示例http://jsfiddle.net/qp7NP/。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句