modal window - need to close modal window AND redirect to another page

Posted on 2009-05-14
Medium Priority
Last Modified: 2012-05-07
hi  - if you mouseover a thumb on this page:


you'll see my modal window - underneath the artwork you'll see a link that says "view larger" - i need this to close the modal window AND redirect to another webpage on the site.  

how can i accomplish this?
Question by:phillystyle123
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
LVL 15

Expert Comment

ID: 24391746
like this?
<script type="text/javascript">
function openModal(){
var returnVal = window.showModalDialog('showModalDialog.html');
alert("returnVal : " + returnVal);
<a href="#" onclick="openModal();">openModal()</a>
modal window
<title>Modal Dialog</title>
      <body >
            <a href="http://www.google.com"  onmousedown="window.returnValue = this.href;window.close();;">Click here</a>

Open in new window


Author Comment

ID: 24394009
wow - just using the example code you provided works but when i actually plug it into the real webpage the window.close part does not. so, it's going to google.com but in the modal window.

check it out here (click on either of the two links under the picture):


here's the code at the top of my main page & modal window:

main page:
<script type="text/javascript" lang="javascript">
var openMyModal = function(source)
	modalWindow.windowId = "myModal";
	modalWindow.width = 575;
	modalWindow.height = 500;
	modalWindow.content = "<iframe width='575' height='500' frameborder='0' scrolling='no' allowtransparency='true' src='" + source + "'>&lt/iframe>";
<script type="text/javascript">
function openModal(){
var returnVal = window.showModalDialog('modal.php');
modal window:(modal.php)
<a href="http://www.google.com"  onmousedown="window.returnValue = this.href;modalWindow.close();">view larger</a> | <a href="http://www.google.com"  onmousedown="window.returnValue = this.href;modalWindow.close();">back to gallery</a>	

Open in new window

LVL 15

Accepted Solution

fsze88 earned 2000 total points
ID: 24395257
try this
<a href="#" onclick="window.parent.location.href='http://www.google.com';">view larger</a>

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 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