?
Solved

Open a new window with self.location.href??

Posted on 2006-03-31
9
Medium Priority
?
5,153 Views
Last Modified: 2008-01-09
I want to open a new page using a button. window.location.href does not seem to work. Is there a way to use this to open the link in a new window.??  I know self opens in the same window.

Thanks!
0
Comment
Question by:baybook
  • 4
  • 3
  • 2
9 Comments
 
LVL 7

Expert Comment

by:bubbledragon
ID: 16343451
window.open() ??
0
 
LVL 7

Expert Comment

by:bubbledragon
ID: 16343565
0
 

Author Comment

by:baybook
ID: 16343653
The link I am opening is site.asp. So u are saying that I should change
self.location.href = site.asp to blank.location.href = site.asp??

 Not working here?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:x4u
ID: 16343672
These will open the page in the current window:
open(urlstr,"_top","",true);  // replaces the all framesets if there have been any
or
open(urlstr,"_self","",true); // opens in current frame
0
 
LVL 11

Expert Comment

by:x4u
ID: 16343681
With your url this would be:
open("site.asp","_top","",true);
0
 

Author Comment

by:baybook
ID: 16351917
I do not think my question is clear... or maybe there is no way for me to do what I am trying to do.

This is my current tag
<input type="button" value="Join Our Newsletter" onClick="self.location.href='join.htm'; ">

Can this (self.location.href='join.htm)  be changed so that the link opens in a NEW window?
In other words, after clicking the button, I will have 2 web browers open.

Thanks
0
 
LVL 11

Accepted Solution

by:
x4u earned 2000 total points
ID: 16352429
This can be done with the open() function too but with another pseudo target: "_blank". You can see short explainations of all pseudo targets here: http://www.codetoad.com/html/frames/specifying_frames.asp

<input type="button" value="Join Our Newsletter" onClick="window.open('join.htm',"_blank",""); ">
In the third paramter you can define several options how the new window is supposed to look like. (see: http://www.blazonry.com/javascript/windows.php) But not all browser respect all of them.

You can also use any other name instead of _blank (and that is not yet used as a frame name) to get a new window and all further clicks would show in this window if it is still open and otherwise reopen it. With "_blank" you get a new window every time you click the link regardless of how many windows are already open.
0
 
LVL 11

Expert Comment

by:x4u
ID: 16352443
oops, I messed up the quotes. They need to be single quotes because the function call occurs in the attribute value that uses double quotes:
<input type="button" value="Join Our Newsletter" onClick="window.open('join.htm','_blank','');">
0
 

Author Comment

by:baybook
ID: 16352460
Thank you for the link.  I have found what I was looking for.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question