Skip to content Skip to sidebar Skip to footer

Open Multiple Child Windows With One Click

I'm trying to open multiple child windows when a single button is clicked. For instance, I have a block labelled '1' and when it is clicked, a corresponding child window with a sh

Solution 1:

Here is a small script that might help you:

<script>functionmyMethod(x){
    alert("Open " + x + ".html");
    if(x-1  > 1) {
        alert("Open " + (x-1) + ".html");
        }
    if(x-8  > 1) {
        alert("Open " + (x-8) + ".html");
    }
    if(x+1  <= 32) {
        alert("Open " + (x+1) + ".html");
        }
    if(x+8  <= 32) {
        alert("Open " + (x+8) + ".html");
    }

     }
</script>

Html:

<body><ahref="#"target="ItsAGoodDay"onClick="myMethod(12)">12</a></body>

You can play around with this to see if you are getting the desired results. Then you can replace the alert with wopen function passing the html name.

Solution 2:

To open multiple child windows with one click, do something like this. You just need to call your wopen multiple times.

functionwopen(url, name, w, h) {
w += 32;
h += 96;
wleft = (screen.width - w) / 2;
wtop = (screen.height - h) / 2;

if (wleft < 0) {
    w = screen.width;
    wleft = 0;
}
if (wtop < 0) {
    h = screen.height;
    wtop = 0;
}
var win = window.open(url,
        name,
        'width=' + w + ', height=' + h + ', ' +
        'left=' + wleft + ', top=' + wtop + ', ' +
        'location=no, menubar=no, ' +
        'status=no, toolbar=no, scrollbars=no, resizable=no');

win.resizeTo(w, h);

win.moveTo(wleft, wtop);
win.focus();
}

document.addEventListener('click', function (e) {
    var win1 = wopen();
    var win2 = wopen();
    var win3 = wopen();
    var win4 = wopen();
    var win5 = wopen();
});

Post a Comment for "Open Multiple Child Windows With One Click"