你如何在对话框的JQUERY UI中打开一个URL [英] How do you open a URL in a dialog box JQUERY UI
问题描述
我尝试了以下操作,但点击链接时对话窗口是空的。
<!DOCTYPE html PUBLIC - // W3C // DTD HTML 4.01 Transitional // ENhttp://www.w3.org/TR/html4/loose.dtd\">
< html>
< head>
< meta http-equiv =Content-Typecontent =text / html; charset = ISO-8859-1>
< title>测试< /标题>
< meta charset =utf-8/>
< link rel =stylesheethref =http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css/>
< script src =http://code.jquery.com/jquery-1.9.1.js>< / script>
< script src =http://code.jquery.com/ui/1.10.1/jquery-ui.js>< / script>
< script>
$(document).ready(function(){
$('#openwindow')。each(function(){
var $ link = $(this);
var $ dialog = $('< div>< / div>')
.load($ link.attr('href'))
.dialog({
autoOpen:false ,
title:$ link.attr('title'),
width:500,
height:300
});
$链接。 click(function(){
$ dialog.dialog('open');
return false;
});
});
} );
< / script>
< / head>
< body>
< a id =openwindowhref =http://www.google.com>点击我进行测试。< / a>
< / body>
< / html>
我找到了几个例子,但没有一个真正起作用。我非常感谢您的帮助。
预先致谢。
您不需要
相反,您需要在 .open
property -
$(#openwindow).dialog({
open:function (event,ui){
$('#divInDialog')。load('test.html',function(){
alert('Load was performed。');
}) ;
}
});
另外,您似乎使用 .each
使用 id
- id
在页面中应该是唯一的。改为使用 class
。
I've been looking for a simple solution for quite some time. I want a page (for example http://www.google.com) to be displayed in a JQuery UI Dialog window. The plan is to later add the URL dynamically so all links from my site will be displayed in said window.
I tried the following, but the dialog window is empty when clicking on the link.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$('#openwindow').each(function() {
var $link = $(this);
var $dialog = $('<div></div>')
.load($link.attr('href'))
.dialog({
autoOpen: false,
title: $link.attr('title'),
width: 500,
height: 300
});
$link.click(function() {
$dialog.dialog('open');
return false;
});
});
});
</script>
</head>
<body>
<a id="openwindow" href="http://www.google.com">Click me to test.</a>
</body>
</html>
I found a few examples, but none actually worked. I'd really appreciate some help.
Thanks in advance.
You don't need an iframe
as has been suggested, but you should read the documentation on dialogs here.
Instead, you need to load the content on the .open
property --
$( "#openwindow" ).dialog({
open: function(event, ui) {
$('#divInDialog').load('test.html', function() {
alert('Load was performed.');
});
}
});
Also, you seem to use .each
with an id
-- the id
is supposed to be unique within the page. use class
instead.
这篇关于你如何在对话框的JQUERY UI中打开一个URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!