1

I have tried target="_blank" and other ways so that below window opens in a new page instead of replacing the current page but its not working.

Can someone would be able to help me get this fixed?

This is the code I am using:

$("#yes").click(function() {
  answer();
  setTimeout(function() {
    $.cookie("answered", "yes", {path:"/", expires:730});
    window.location = "http://www.google.com", "_blank"
  }, 2E3)
});
1
  • $("#yes").click(function(){answer();setTimeout(function(){$.cookie("answered","yes", {path:"/",expires:730});window.open("http://www.google.com")},2E3)}); Commented Sep 11, 2014 at 16:17

3 Answers 3

3

window.open:

Loads a resource into either a new browsing context (such as a window) or one that already exists, depending on the specified parameters.

syntax:

var windowObjectReference = window.open(strUrl, strWindowName[, strWindowFeatures]);
Sign up to request clarification or add additional context in comments.

Comments

2

You need to use window.open instead:

window.open('url', 'name', 'window settings')

Check this Online Demo and window open documentation

name is optional. Specifies the target attribute or the name of the window. The following values are supported:

  • _blank - URL is loaded into a new window. This is default
  • _parent - URL is loaded into the parent frame
  • _self - URL replaces the current page
  • _top - URL replaces any framesets that may be loaded

or name - The name of the window

window settings is optional.

Comments

0

window.open() is a method that you can pass a URL to that you want to open in a new window. For example:

window.open() example:

window.open('http://www.google.com'); //This will open Google in a new window

Additional Information:

window.open() can be passed additional parameters. See:window.open tutorial

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.