javascript - How to open link in popup box? - Stack Overflow

I'd like to openthis link as a popup box:<a href="upload" onclick="window.op

I'd like to open this link as a popup box:

  <a href="/upload/" onclick="window.open(this.href, 'windowName', 'width=500, height=350, left=24, top=24, scrollbars, resizable'); return false;">Upload pic</a>

Currently, it opens in a window, but what I want is a bare popub box instead. How to do so using js or jQuery?

Update: The link is inside a form group and using iframe, as suggested by many here, causes the form to submit (not sure why though). So I look for a non-iframe solution.

I'd like to open this link as a popup box:

  <a href="/upload/" onclick="window.open(this.href, 'windowName', 'width=500, height=350, left=24, top=24, scrollbars, resizable'); return false;">Upload pic</a>

Currently, it opens in a window, but what I want is a bare popub box instead. How to do so using js or jQuery?

Update: The link is inside a form group and using iframe, as suggested by many here, causes the form to submit (not sure why though). So I look for a non-iframe solution.

Share Improve this question edited May 23, 2017 at 12:14 CommunityBot 11 silver badge asked Apr 25, 2015 at 3:17 JandJand 2,73715 gold badges39 silver badges68 bronze badges 1
  • Look at jQuery UI jqueryui./dialog – Prashanth Subramanian Commented Apr 25, 2015 at 3:22
Add a ment  | 

2 Answers 2

Reset to default 2

Build your own popup box with an iframe element;

onclick you can change the src of the iframe to the one you want


document.getElementById('modalBtn').onclick = displayPopup;

function displayPopup() {
  var popup = document.getElementById("popup");
  var frame = document.getElementById('popupFrame');
  frame.src = "https://www.bing.";
  popup.style.display = "block";
}
#popup {
  width: 320px;
  height: 300px;
  margin: 0 auto;
  box-shadow: 1px 1px 1px 1px black;
  display: none;
}
#popup iframe {
  width: 100%;
  height: 100%
}
<div id="popup">
  <iframe id="popupFrame" src=""></iframe>
</div>

<button id="modalBtn">Display Popup</button>

Whoops.. misread your question

Re-answer:

Use jQuery.

$(document).ready(function (){
    $("#testButton").click(function() {$('#overlayContainer').show();});
});

Jsfiddle Demo

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745368325a4624684.html

相关推荐

  • javascript - How to open link in popup box? - Stack Overflow

    I'd like to openthis link as a popup box:<a href="upload" onclick="window.op

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信