|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Close window when opening new window
I have a site with several pictures scattered throughout that pops up another window for a larger view. Three of the pictures are from an art institute. The condition for use is that a link to the institute must be accessible from the picture.
The sequence of events: Small image clicked –large image opens in a new window Link on large image clicked –institute site loads in a new window Now the visitor has three windows open, the parent window, large image window and the institute. Too many. What I’ve been struggling with is trying to close the large image window when loading the institute window. Strange things have happened. I’ve gone from getting a prompt that the web page is trying to close the window (not very professional) to closing before it even finishes opening. Any suggestions would be greatly appreciated. Thanks |
|
#2
|
||||
|
||||
|
You will only get the warning if you attempt to close a window you did not create - and from you have described, this is not what you want to do anyway - you are trying to close the pop up (large image). In the large image window, create a JS function which first, generates a new window for the institute link, then closes itself... e.g.
Code:
<script type="text/javascript">
function viewInstitute(url) {
x = window.open(url,"popInstitute",your window features)
this.close()
}
</script>
<!-- the HTML -->
<a href="#" onclick="viewInstitute('http://wwww.blah.com')"><img src="images/blg.jpg" alt="" /></a>
|
|
#3
|
|||
|
|||
|
Thanks for responding, you were a tremendous help. It wasn’t until reading your message that I realized my problem.
I was testing the window.close() from the large image window. Obviously it would prompt that the web page is trying to close the window because it was the parent. Don’t know where my mind was but appreciate you giving me a jump start. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Close window when opening new window |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|