使用javascript或php在新窗口中打开模态

时间:2016-02-17 16:23:18

标签: javascript php jquery html codeigniter

我尝试在新标签中点击链接并将当前页面重定向到另一个链接时加载模式。像点击优惠券时零售店所做的事情。这是我的代码:

<div onClick="myFunction()">
    <a href="<?=site_url();?>deal/coupon_detail/<?=$row->deal_id;?>" class="get-code" data-toggle="modal" data-target="#copy_code<?=$i;?>" id="myModal">
        <?php echo $_SESSION['LANG']['lbl_home_get_code_text'];?>
    </a>
 </div>  
<script>
    function myFunction() {
        var newWindow= window.open("<?=site_url();?>",'_blank');
        $(newWindow).load(function() {
            newWindow.location=document.getElementById('myModal').href;
        });                          
        window.open("<?=site_url();?>deal/deal_exitclick_id/<?=$row->store_id;?>/<?=$row->deal_id;?>",'_self');    
    }
</script>

我试图打开的模式是在其他类中:

<div id="myModal">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">&times;</button>
  </div>
  <div class="modal-body copycode">
    <h4>Here's your Coupon Code</h4>
    <p>Paste this code at checkout when you are done shopping.</p>
    <span class="get-code" id="voucher_code_<?=$coupon->deal_id?>_get"><?=$coupon->voucher_code;?></span>
    <p><a class="copy-code" target="_blank" id="<?=$coupon->deal_id?>" href="<?=site_url();?>deal/deal_exitclick_id/<?=$store->store_id;?>/<?=$coupon->deal_id;?>">Copy Code</a>
    </p>
    <a target="_blank" href="<?=site_url();?>deal/deal_exitclick_id/<?=$store->store_id;?>/<?=$coupon->deal_id;?>">Click here to go to <?=$store->name;?> >>></a>
  </div>
</div>

1 个答案:

答案 0 :(得分:0)

您可以打开一个打开文件的弹出窗口:

<a href="#" onclick="window.open('your/file/path','', 'width=200, height=100')">Click here</a>
<a href="#" onClick='window.open("", "", "width=200, height=100")'>Click here</a>

Demo