使用url params打开Bootstrap打开。

时间:2022-06-06 11:57:27
 <a class="activate_button" href="{{w.LandingPageURL}}" ng-click="newwindow(w)" data-toggle="modal" data-target="#{{w.CouponID}}">DEAL</a>  

<div class="modal fade coupon_popup" id="{{w.CouponID}}" tabindex="-1" role="dialog" aria-labelledby="{{w.CouponID}}" aria-hidden="true">

I am trying to open popup using url params.

我正在尝试使用url params打开弹出窗口。

For example my url www.dadad/asdada#{{w.CouponID}}

例如,我的url www.dadad/asdada#{

then need to open that id popup. I am using bootstrap.js v3.0.0

然后需要打开那个id弹出窗口。我用引导。js v3.0.0

2 个解决方案

#1


2  

Add a JavaScript code like this,

添加这样的JavaScript代码,

var x=location.hash.substring(1);
$('#myModal').attr({"id": x},{"aria-labelledby":x}); 
$('#'+x).modal();

No changes in HTML

HTML没有变化

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

Demo

演示

#2


0  

If you are using bootstrap modal popup means:

如果您使用bootstrap模式弹出方式:

Use iframe in your modal popup and pass the url to it.

在您的模式弹出窗口中使用iframe并将url传递给它。

If you are opening new popup window means:

如果您正在打开新的弹出窗口,意味着:

Use this

使用这个

var url = 'www.dadad/asdada#{{w.CouponID}}';
window.open(url, 'Title', 'width=900px,height=900px,left=50px,scrollbars=1,resizable=1');

#1


2  

Add a JavaScript code like this,

添加这样的JavaScript代码,

var x=location.hash.substring(1);
$('#myModal').attr({"id": x},{"aria-labelledby":x}); 
$('#'+x).modal();

No changes in HTML

HTML没有变化

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

Demo

演示

#2


0  

If you are using bootstrap modal popup means:

如果您使用bootstrap模式弹出方式:

Use iframe in your modal popup and pass the url to it.

在您的模式弹出窗口中使用iframe并将url传递给它。

If you are opening new popup window means:

如果您正在打开新的弹出窗口,意味着:

Use this

使用这个

var url = 'www.dadad/asdada#{{w.CouponID}}';
window.open(url, 'Title', 'width=900px,height=900px,left=50px,scrollbars=1,resizable=1');