0

Can anyone see why the following code is not causing my url top open up in a new window, i.e:

        $(location).attr({
            href: toLoad,
            target: "_blank"
        });

where toLoad is my url.

Looking at the view source, all seems fine and basically looks like:

<a target="_blank" title="" href="http://......etc">ccc</a>

Any ideas what I could be doing wrong?

Thanks.

3
  • You want it to immediately open, or when clicked? Commented Mar 8, 2010 at 12:21
  • Seems a little unclear, you want it to open a new window? and - close thise one? or just open a new one? And, when is this action to take place, on the click of the link or something else, or on the page open? Commented Mar 8, 2010 at 12:53
  • Want it to open when clicked into a new window. Commented Mar 8, 2010 at 14:13

1 Answer 1

1

The jQuery wrapper is used for DOM elements, not arbitrary objects, and location (window.location) doesn't even have a target attribute. Simply do a window.open(...).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.