Hi! to make this short, this is my problem, i have multiple links which open new windows on one page, this is an example of the code used to call the function for this action <div align="top"> <a href="" onClick="Javascript:blogNewWindow(210906, 'Getting the gear in order');return false"> <img src="blog/blog210906.jpg"><br><i>"Getting the gear in order"</i></a></div> Code (markup): This is the function (in an external script): function blogNewWindow(whichWindow, caption) { blogNewWindow=window.open('','name','height=570, width=700, left=50,top=50,screenX=50,screenY=50') var blogImageWindow = blogNewWindow.document var blogWhichImage = '<img src="blog/blog'+whichWindow+'Big.jpg">' blogImageWindow.write('<html><head><title>Blog - Full Size Images</title>') blogImageWindow.write('<link rel="stylesheet" href="portfolioStyleSheet2.css">') blogImageWindow.write(blogWhichImage) blogImageWindow.write('<p align="center">') blogImageWindow.write('<font class="bodyText"><i>"') blogImageWindow.write(caption) blogImageWindow.write('" || </i></font>') blogImageWindow.write('<font class="bodyText"><a href="javascript:self.close()">close</a> this window.</font>') blogImageWindow.write('</body></html>') blogImageWindow.close() } Code (markup): It all works fine, but for some reason it only works once, so, if you click on one link to open a new window it works, but if you click on another link to open another window (even when the first new window is closed) it doesnt work, yet, clicking on the link, again, makes it work, so essentially, you have to click twice on any 'new window' link after the first time to create the new window. Any thoughts? Cheers people
Yes. Don't open new windows. It's simply a hindrance to users who actually know how to use their browser to do it, or prefer not to, or use tabs... the list goes on.
Hi Prowlie, The problem is that the variable that you assign the new window to 'blogNewWindow' is global. This means that the first time you run the function it works (because blogNewWindow is uninitialised). The second time you run it, it is already set to the first window. The easy way around this is to declare blogNewWindow as local to your function. Eg: This worked for me. function blogNewWindow(whichWindow, caption) { var blogNewWindow; blogNewWindow=window.open('','name','height=570, width=700, left=50,top=50,screenX=50,screenY=50') var blogImageWindow = blogNewWindow.document var blogWhichImage = '<img src="blog/blog'+whichWindow+'Big.jpg">' blogImageWindow.write('<html><head><title>Blog - Full Size Images</title>') blogImageWindow.write('<link rel="stylesheet" href="portfolioStyleSheet2.css">') blogImageWindow.write(blogWhichImage) blogImageWindow.write('<p align="center">') blogImageWindow.write('<font class="bodyText"><i>"') blogImageWindow.write(caption) blogImageWindow.write('" || </i></font>') blogImageWindow.write('<font class="bodyText"><a href="javascript:self.close()">close</a> this window.</font>') blogImageWindow.write('</body></html>') blogImageWindow.close() } Cheers.