Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using location.href and a new window 1

Status
Not open for further replies.

senglish

Programmer
Nov 4, 2002
19
AU
I am using the code below to generate a url and I want it to open in a new window. This code displays it in the current window.

function CreateRSS(inform)
{
var RSStext = "location.href=RSStext + inform.options[2].value;
}
I am calling it from here
<INPUT type="button" value="Search Now" name="FormsButton1" onclick="CreateRSS(subheading);" size="20">
</INPUT>

How can I add the HTML equivalent of target="_blank" to open it in a new window please?
Thank you
Stephen
 
[tt]location[/tt] refers to the location object of the calling document. So replacing the [tt]href[/tt] of [tt]location[/tt] does what you are finding... sends the current browser window to the specified url.

To open a new window use the [tt]window.open()[/tt] method

Code:
function CreateRSS(inform)
{
var RSStext = "[URL unfurl="true"]http://dcw.salisbury.sa.gov.au/site/page.cfm?u="[/URL]
var newWin = window.open(RSStext + inform.options[2].value, "newWin");
}

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

AU.gif
Check out Tek-Tips Australia New Zealand forum1155
NZ.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top