Solved

javascript popup problem

Posted on 2006-07-04
4
442 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now