Link to home
Start Free TrialLog in
Avatar of MJ
MJFlag for United States of America

asked on

Pass an optional argument while using the Arguments Object

Is it possible to use the argument object and still pass in a flag (Boolean)?  I need to have the flexibility of processing multiple possible arrays passed in and at the same time have an option flag passed when necessary. Is that possible and if so, how? So for an example I'd like to have the following type of functionality (there will always be at least one array passed in):
_dtmInsertStaticTags(arr1)
_dtmInsertStaticTags(arr1,arr2)
_dtmInsertStaticTags(arr1,flag)
_dtmInsertStaticTags(arr1,arr2,arr3,flag)
_dtmInsertStaticTags(arr1,arr2,arr3,arrN)
_dtmInsertStaticTags(arr1,arr2,arr3,arrN,flag)
function _dtmInsertStaticTags() {


    var sTags = [];
    for (var index = 0; index < arguments.length; index++) {
        sTags = sTags.concat(arguments[index]);
    }

    //routine to inject detokenized src values into container iframe
    var iframeTag = document.createElement("iframe");
    iframeTag.setAttribute("width", "1");
    iframeTag.setAttribute("height", "1");
    iframeTag.style.display = "none";
    iframeTag.style.border = "none";

    for (var i = 0; i < sTags.length; i++) {
        var imgTag = document.createElement("img");
        imgTag.src = sTags[i];
        iframeTag.appendChild(imgTag);
    }

    if (window.addEventListener) {
        window.addEventListener("load", function () { document.body.appendChild(iframeTag); }, false);
    } else {
        window.attachEvent("onload", function () { document.body.appendChild(iframeTag); });
    }
};

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jan Louwerens
Jan Louwerens
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial