How do I display image in Alert/confirm box in Javascript?

前端 未结 7 2369
终归单人心
终归单人心 2020-12-06 01:27

How to display image in alert box or confirm box? I have been trying with below code but getting image url in the alert box. Please anybody help me to get solve or please gi

7条回答
  •  有刺的猬
    2020-12-06 02:06

    I created a function that might help. All it does is imitate the alert but put an image instead of text.

    function alertImage(imgsrc) {
    $('.d').css({
        'position': 'absolute',
        'top': '0',
        'left': '50%',
        '-webkit-transform': 'translate(-50%, 0)'
    });
    $('.d').animate({
        opacity: 0
    }, 0)
    $('.d').animate({
        opacity: 1,
        top: "10px"
    }, 250)
    $('.d').append('An embedded page on this page says')
    $('.d').append('
    ') $('.b').css({ 'position':'absolute', '-webkit-transform': 'translate(-100%, -100%)', 'top':'100%', 'left':'100%', 'display':'inline', 'background-color':'#598cbd', 'border-radius':'4px', 'color':'white', 'border':'none', 'width':'66', 'height':'33' }) }
    
    
    .d{
    font-size: 17px;
      font-family: sans-serif;
    }
    .b{
      display: none;
    }
    

提交回复
热议问题