简体   繁体   English

带iframe的jquery对话框

[英]jquery dialog box with iframe

I'm trying to use the jquery ui dialog box to output an iframe. 我正在尝试使用jquery ui对话框输出iframe。 It doesn't seem to be working for me. 它似乎对我不起作用。 I think I am making a syntax mistake somewhere- probably with quotation marks in the iframe. 我认为我在某个地方犯了语法错误-可能是iframe中的引号。 Any help would be much appreciated. 任何帮助将非常感激。

<a href='' onclick=\"open_course_article('$userid','$title', 'remove', '$sel_course');\">Remove from Course</a>

   function open_course_article(userid,article,option,course) {
        $('<iframe src="article_course.php?option="+option+"&userid="+userid+"&course="+course+"&article="+escape(article)"/>').dialog({
        title: 'Add Article',
        width: 600,
        height: 400,
        modal: true,
        }).width(570).height(370);
     }

You are mixing single quotes with double quotes for enclosing a string , which does not work in programming. 您正在将单引号和双引号混合在一起以封闭字符串 ,这在编程中不起作用。

$('<iframe src="article_course.php?option="+option+"&userid="+userid+"&course="+course+"&article="+escape(article)"
 />')

should be something more like: 应该更像是:

$('<iframe src="article_course.php?option='+option+'&userid='+userid+'&course='+course+'&article='+escape(article)+'"
 />')

The jquery selector you have specified is wrong. 您指定的jquery选择器是错误的。 I believe you have an tag somewhere in your html. 我相信您在html的某处有一个标记。 Select iframe this way 这样选择iframe

  $('iframe').dialog{ ...}

or if you have other iframes in your html then you will have to provide some unique attribute...lets say id in which case: 或者,如果您的html中还有其他iframe,则您必须提供一些唯一的属性...在这种情况下,请说出id:

   $('iframe #idvalue').dialog{ ...}

please show your html file for us to be able to help better 请显示您的html文件,以便我们更好地提供帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM