Solved

javascript popup problem

Posted on 2006-07-04
4
447 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

738 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