Solved

javascript popup problem

Posted on 2006-07-04
4
445 Views
Last Modified: 2010-05-18
My javascript is not great.

I use this to open a window

function popup(url, dimensions)
{
      newwindow=window.open(url,'name', dimensions);
      if (window.focus) {newwindow.focus()}
}

with the links

<a href="javascript:popup('delivery&returns.php', 'height=450,width=270');">delivery&returns </a> |

<a href="javascript:popup('contact.php', 'height=300,width=350');">contact</a>


The problem is if I click on one then another the new page is put in the 'old' window wich is the wrong dimensions. any ideas?

Ross
0
Comment
Question by:roscoeh23
  • 2
4 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 17037047
Hi roscoeh23,

You have to change the 'name' for each popup, otherwise the same named window will be reused.

function popup(url, dimensions,what)
{
     newwindow=window.open(url,what, dimensions);
     if (window.focus) {newwindow.focus()}
}

with the links

<a href="javascript:popup('delivery&returns.php', 'height=450,width=270','big');">delivery&returns </a> |

<a href="javascript:popup('contact.php', 'height=300,width=350','small');">contact</a>


Tim Cottee
0
 
LVL 1

Accepted Solution

by:
dnlakhani earned 500 total points
ID: 17040187
<script>
function popup(url, dimensions,name)
{
     newwindow=window.open(url,dimensions,name);
     if (window.focus) {newwindow.focus()}
}
</script>

change the name for different window

<a href="javascript:popup('delivery&returns.php', 'height=450,width=270','test');">delivery&returns </a> |

<a href="javascript:popup('contact.php', 'height=300,width=350','test11');">contact</a>
0
 

Expert Comment

by:Tahir_Imran
ID: 17071422
THis will always work for you :
function popup(url, dimensions,what)
{
    day = new Date();
    id = day.getTime();
  newwindow=window.open(url,id, dimensions);
}

with the links

<a href="javascript:popup('delivery&returns.php', 'height=450,width=270','big');">delivery&returns </a> |

<a href="javascript:popup('contact.php', 'height=300,width=350','small');">contact</a>
0
 

Expert Comment

by:Tahir_Imran
ID: 17071430
a Sight modification , No need to pass what
THis will always work for you :
function popup(url, dimensions)
{
    day = new Date();
    id = day.getTime();
  newwindow=window.open(url,id, dimensions);
}

with the links

<a href="javascript:popup('delivery&returns.php', 'height=450,width=270');">delivery&returns </a> |

<a href="javascript:popup('contact.php', 'height=300,width=350');">contact</a>
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question