OnClick to open in same window?

How must I chnage this code to get this ref to open in the same window or at least close the calling window. I do not wnat the full path to display. That is why I am using the "href=#". Here is my code:


...............
<a href=# onClick="window.open('http://gisweb/liquor_license/secret/index.htm')" ><img src="button2.gif" height="15" width="15" border="0" alt="Edit Liquor License Database" align="middle">
.......
apwbeAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
b1xml2Connect With a Mentor Commented:
<a href=# onClick="window.open('http://gisweb/liquor_license/secret/index.htm','_same')" ><img src="button2.gif" height="15" width="15" border="0" alt="Edit
Liquor License Database" align="middle"></a>
.......

the window.open method has three widely params
<url>,<name>,<features>

you by specify the name (the same for all the links with your struct) so that the same window will be re-used
0
 
thirdCommented:
how about,

<a href="http://gisweb/liquor_license/secret/index.htm" onmouseover="window.status='click here...';" onmouseout="window.status='';"><img src="button2.gif" height="15" width="15" border="0" alt="Edit Liquor License Database" align="middle"></a>
0
 
b1xml2Commented:
hehehe third, we meet again!!!
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
thirdCommented:
hehehe it's a small world!

i'm thinking also the same with you but i realized he stated he don't wanna display the full path so i think he is referring to the status bar display. anyway, both code works! ;-)
0
 
apwbeAuthor Commented:
Third,

I could not get yours to work.

b1xml2,

I got you chnage to work but had to change the "_same" to "_top" and it works like I wnated it to.

Thanks guys
0
 
b1xml2Commented:
the _same is a string, it could be any name, doesnt matter!
0
 
b1xml2Commented:
This shows that what you have asserted is incorrect. The name of the window is a STRING and it doesnt matter what the STRING value is except that it must be the same.

<html>
<head>
<title>Reusable Window</title>
</head>
<body>
<a href="#" onclick="window.open('http://www.microsoft.com','_same')" ><img src="../images/collapse.gif" border="0" alt="Microsoft.COM" align="middle"></a>
<a href="#" onclick="window.open('http://www.ibm.com','_same')" ><img src="../images/collapse.gif" border="0" alt="IBM.COM" align="middle"></a>
<a href="#" onclick="window.open('http://www.cisco.com','_same')" ><img src="../images/collapse.gif" border="0" alt="Cisco.COM" align="middle"></a>
</body>
</html>

Any expert can test this with NS4.x,MSIE4+(4 or higher), NS6.x and will find the window re-usable.

I object also to the grade B.
0
 
b1xml2Commented:
and may I add, the list of black-listed users by me has just grown by 1 today!
0
 
thirdCommented:
i do agree with you, b1xml2. you deserve an A.


another workaround would be,

<a href="#" onclick="window.location='http://www.google.com';return false;">
<img src="button2.gif" height="15" width="15" border="0" alt="Edit Liquor License Database" align="middle"></a>

0
 
b1xml2Commented:
thank you, third for your independent verification =)))
0
 
apwbeAuthor Commented:
Sorry if I offended anyone as I am no expert and you guys are. Please accept my apology. All I know is that changing the _same string to _top made the code work the way I wanted it to. Most likely operator error or something I did not notice.

Thanks again.

ps

b1xml2,

Please explain the black_listed users comment. I certainly did not intend to insult someone with my acceptance of your answer. Do you mean that I am suppose to give the expert an automatic A if I accept their answer or do you mean that if you do not get an A you do not want to play?
0
 
reallynicejerkCommented:
b1xml2, if I'm not mistaken you're simply confused about what he was trying to do.

Your link opens in a new window which is then reused everytime a link is opened with that same window name.  This is basic HTML linking and is carried through into javascript. There is no need for the underscore in the page title although it still works. The only underscore titles that are recognized by browsers are _blank _parent _self and _top.  

However, what apwbe was trying to do was use onclick to open a link in the current browser window. The targets _parent _self and _top would do so as long as he was not using frames. If he was using frames the only target title that would work would be _self. _parent would open the browser in the parent frameset and _top would open in the same browser window without any framesets above it.

Third's answer of using window status to solve the problem was even more off of what he was trying to do, and isn't effective as 1 users can simply right click on the link to reveal the url, 2, many third party browser plugins disable altering of the status bar and 3, window.status only works in internet explorer as far as I know (atleast it doesn't work in my versions of Netscape, Mozilla, Opera, or any of the other browsers that came with redhat linux 8.0 (I never really paid attention to their names, just tried them out a few times)).

Not to step on anyone's toes here, but I have to say that I agree with the grade of the B as the whole point of the question was to find out how to use onclick to open in the same window, you simply told him how to use onclick.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.