MrGlasspoole
MrGlasspoole

Reputation: 445

Commas in Javascript if statements?

Sorry for this maybe stupid question, but how can I use commas in if statements? This is the normal part:

  $("a[rel*=overlay]").overlay({
    fixed: false,
    closeOnClick: false,
      onBeforeLoad: function() {
        var wrap = this.getOverlay().find("#contentWrap");
        var eID = this.getTrigger().attr("id").replace(/.$/g, '');
        var hiURL = document.location.href;
        var eURL = this.getTrigger().attr("href");
        var stateObj = { foo: "bar" };
        wrap.load(this.getTrigger().attr("href"));
        window.location.hash = (eID);
      },
  onClose: function() {
        window.something(something);
  }
  });

I need:

  $("a[rel*=overlay]").overlay({
    fixed: false,
    closeOnClick: false,
      onBeforeLoad: function() {
        var wrap = this.getOverlay().find("#contentWrap");
        var eID = this.getTrigger().attr("id").replace(/.$/g, '');
        var hiURL = document.location.href;
        var eURL = this.getTrigger().attr("href");
        var stateObj = { foo: "bar" };
        wrap.load(this.getTrigger().attr("href"));
        if (Modernizr.history) {
          window.history.replaceState(currentPage, document.title, eURL);
          },
            onClose: function() {
              window.history.replaceState(currentPage, document.title, "dort");
        } else {
        window.location.hash = (eID);
        }
      }
  });

But the "}," shows an error in dreamweaver.

Upvotes: 0

Views: 334

Answers (1)

CrazyDart
CrazyDart

Reputation: 3801

EDIT: I have replaced my orig answer with this one, thus making most of the comments invalid. At the time I posted the author had not given enough info to solve the problem, and I had a typo in my pseudo answer.

You where close to getting it correct, just missing one bracket...

  $("a[rel*=overlay]").overlay({
    fixed: false,
    closeOnClick: false,
      onBeforeLoad: function() {
        var wrap = this.getOverlay().find("#contentWrap");
        var eID = this.getTrigger().attr("id").replace(/.$/g, '');
        var hiURL = document.location.href;
        var eURL = this.getTrigger().attr("href");
        var stateObj = { foo: "bar" };
        wrap.load(this.getTrigger().attr("href"));
        if (Modernizr.history) {
          window.history.replaceState(currentPage, document.title, eURL);
        } // <-- Missing this one
      },
      onClose: function() {
          window.history.replaceState(currentPage, document.title, "dort");
        } else {
          window.location.hash = (eID);
        }
      }
  });

Upvotes: 1

Related Questions