[RESOLVED]pop image when i open webistte

hi

here i try to create a pop up

i host my website but here i want to when i open webiste then image will be display as a pop up 

here i try to write some code

<head
<script type="text/javascript">

       function openWin(img){

           var path = "images/"

           window.open(path+img,"mywin","menubar=0,resizable=0,width=200,height=200")
                            }
    </script>
</head>

<body>
<a href="javascript:openWin('abc.jpg')">open window</a>
</body>

but here i dont want this a .. it show me like when i click an open window then image is open but i dont want this

i want image just display without clicking anyplace or mousehover any place and also i want when i close this image i click outside the image anywhere and then image should be closed

so how i create this one?

any help?

Hi Bakhtawar,

Thanks for your post.

You could try the below code. When document is ready, the popup window will display automatically. And if user click outside the image then image will be closed.

$(function () {
    var popup_window = window.open("imagepath", "_blank ", "width=200, height=200");
window.onclick = function () {
        popup_window.close();
} 

Hope it will be helpful to you.

Best Regards,

Fei Han

thank u for your reply… can you please tell me how to call this function in html?

Hi Bakhtawar,

Bakhtawar Ashiq

can you please tell me how to call this function in html?

You should add a javascript reference and put this javascript code in <head> section as below. After the DOM has been initialized, the code will be executed immediately.

<head runat="server">
    <title></title>
    <script src="../../Scripts/jquery-1.8.2.js"></script>
    <script>
        $(function () {
            var imagepath = "../../Images/2.png";
            var popup_window = window.open(imagepath, "_blank ", "width=200, height=200");
            window.onclick = function () {
                popup_window.close();
            }
        })
    </script>
</head>

Best Regards,

Fei Han

Leave a Reply