Web Analytics Made Easy -
StatCounter Generic New Window Script - CodingForum

Announcement

Collapse
No announcement yet.

Generic New Window Script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generic New Window Script

    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

    Code:

    Code:
    <div align="top">
    <a href="" onClick="Javascript:blogNewWindow(100906, 'Leaving the Cottier Behind');return false">
    <img src="blog/blog100906.jpg" border="1"><br><i>"Leaving the Cottier Behind"</i></a></div>
    This is the function (in an external script):

    Code:

    Code:
    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()
    	}
    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

  • #2
    Rename your function BlogNewWindow1. Its name is conflicting with the variable you assigned to your new window.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

    Comment

    Working...
    X