Link to home
Start Free TrialLog in
Avatar of apwbe
apwbeFlag for United States of America

asked on

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">
.......
Avatar of third
third
Flag of Philippines image

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>
ASKER CERTIFIED SOLUTION
Avatar of b1xml2
b1xml2
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hehehe third, we meet again!!!
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! ;-)
Avatar of apwbe

ASKER

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
the _same is a string, it could be any name, doesnt matter!
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.
and may I add, the list of black-listed users by me has just grown by 1 today!
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>

thank you, third for your independent verification =)))
Avatar of apwbe

ASKER

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?
Avatar of reallynicejerk
reallynicejerk

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.