F. M.
F. M.

Reputation: 509

Open 2 windows javascript

How do I use javascript to redirect the current page and also open another popup window! would that be possible? is there a risk? thank you

Update:

  I am trying now to: 
  var myid=  "<xsl:value-of select="@ID" />"
  which works for
  document.location.href = http://... + myid
 but won't work for 
 window.open=("http://... "+ myid)

Any idea what I am doing wrong. the is no value with windo.open

Upvotes: 0

Views: 214

Answers (4)

Chris Montgomery
Chris Montgomery

Reputation: 2354

1 open new window

window.open("http://stackoverflow.com/")

2 redirect

window.location = "http://stackoverflow.com/"

Note: order is important here.

Upvotes: 2

John Koerner
John Koerner

Reputation: 38077

Use can use window.open to open a new window:

window.open("http://www.example.com");

You can update the document's location to do a simple redirect:

document.location = "http://www.example.com";

The draw backs of doing this is that additional windows tend to annoy users if they are not expecting it and some browsers/pop-up blockers will simply not allow the new window to open.

Upvotes: 1

CrayonViolent
CrayonViolent

Reputation: 32532

You can make javascript load a new page by changing the value of location.href

You can make javascript open a new popup window by using window.open()

FYI many browsers and addons will either prompt a visitor to allow/deny the popup, or flat out deny it.

Upvotes: 1

Aesthete
Aesthete

Reputation: 18848

Redirect:

window.location.href = "http://someothersite.com";

Popup:

window.open("http://somepopup.com","newWindowNameHere");

There are various features you can specify on your new window. See this reference.

Upvotes: 1

Related Questions