View Full Version : Retaining the main window while opening new window
raghavan20
01-28-2005, 07:08 PM
Hi all,
I had created a link. when the user clicks on it, the new link should come up but the old link should remain in the same page.
I could do the above by:
<a href="homepage.asp" onClick="window.open'http://www.altavista.com')">ALTAVISTA</a>
Instead of using homepage.asp at the href value , i want to some property to maintain the same page.
Could you suggest alternate methods to do the same.
Thank you
_Aerospace_Eng_
01-28-2005, 08:05 PM
okay if i understand u correctly u want the href to be ignored and the window to open
<a href="javascript:;" onClick="window.open('http://www.altavista.com')">ALTAVISTA</a>
but if that is what u want to do then y not just have a normal link but u may be wanting to open the href in the page and also the window open if that is the case try this instead
<a href="homepage.asp" onClick="window.open('http://www.altavista.com')">ALTAVISTA</a>
sorry if i totally misunderstood u
raghavan20
01-28-2005, 08:44 PM
hi, its nice u have replied to my query .
I was thinking of the browser to automatically know the parent window from which the new window was opened.
it should be able to retain the parent window by somehow.
i was wonderin whether there would be sth like parent.url in the href instead of giving in the direct target file .
when I type wot u have told.
<a href="java script:;" onClick="window.open('http://www.altavista.com')">ALTAVISTA</a>..it opens this page
http://raghavan/brinkster/aspfiles/java%20script:;
..which is not I wanted
i dont know whether iam able to express properly or wrong in my thought.
_Aerospace_Eng_
01-28-2005, 09:04 PM
u have to take the space out of the word javascript for what i posted to work
raghavan20
01-29-2005, 07:40 AM
Hi,
Thank you very much mate..I took off the white space and the program works as I intended. Thank you for your valuable suggestion.
If you dont bother, Could you explain me how this works..I want to know the logic associated with it.
_Aerospace_Eng_
01-29-2005, 11:50 AM
u just need to put something in the href that tells it to ignore it basically, u can even put just a # sign there and that will be fine, it will add a little pound sign to the link in the address bar though, which is y i used javascript:; but the better way would be to use a return false on the end so it uses a built in function and should still work even if the user has javascript disabled
<a href="http://www.altavista.com" onclick="window.open('http://www.altavista.com');return false">ALTAVISTA</a>
if javascript is disabled then the link will open normally but doing what u are doing is almost like using target="_blank" in the a tags that is of course u would want to change the window attributes
raghavan20
01-29-2005, 08:08 PM
Thank you very much for your descriptive explanation. Could you suggest some good sites to learn more on <a>tags and the window and the target properties.
I am actually not good with the concepts of the blank,parent and child. I was looking for a long time to find some good tutorials which deal with them.
_Aerospace_Eng_
01-30-2005, 03:00 PM
try this site it has a lot of useful info and some good tutorials http://www.w3schools.com/
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.