如何在javascript中从灯箱中的按钮调用iframe的功能

时间:2013-11-12 10:42:01

标签: javascript php iframe joomla

调用JS函数时遇到一些问题,该函数在灯箱中的iframe源中定义。这是我到目前为止所尝试的代码,

的index.php

<iframe id="commentframe" src="index.php?option=com_excelvision&view=livevideo&layout=commentiframe&tmpl=component2&ev_id=<?php echo $result[0]->id;?>" width="950px" height="450px"></iframe> 

commnentframe.php

<script>
function comments(ev_id,text,name,email)
{
var comment=text;
jQuery.ajax({
    type: "POST",             
    url:'index.php?option=com_excelvision&controller=excelvision&task=subcomment',
    data: {body:comment,eventid:ev_id,name:name,email:email},
    success: function(data) {
        //console.log(data)
    }
});
}
</script>
<?php 
JHTML::_('behavior.modal'); 

?>
<div class="jointhe">
<img src="<?php echo JURI::root();?>templates/excel/images/conv_icon.png">
<a href="<?php echo JURI::root().'index.php?option=com_excelvision&view=comment&tmpl=component1&ev_id='.$_REQUEST['ev_id'];?>" class="modal" >Join The Conversation</a>
</div>
<br/>
<div id="prev_comment">

<div id="com_det1">
    <div id="com_det">
        Commnets is loading.......
    </div>
    </div>
</div>

comment.php

<a onclick="window.parent.comments('<?php echo $_REQUEST['ev_id']?>',$('.commnenttext').val(),$('#name').val(),$('#email').val());window.parent.SqueezeBox.close();" class="button_org">Submit Commnet</a>

在上面的代码中,我从commentframe中的iframe调用了视图布局index.php,在iframe中,点击链接指示灯框时会有注释链接在iframe中打开,并且在点击它时有一个发布评论的链接,它应该调用我在commnetframe.php中定义的commnents函数。我试图这样做window.parent.myfunctionname()但它没有用。如果有人有任何解决方案,请帮助。

0 个答案:

没有答案