Solved

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

Posted on 2009-05-14
3
677 Views
Last Modified: 2012-05-07
hi  - if you mouseover a thumb on this page:

http://ctemps.cjehost.com/subgallery_4column_with.php

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?
0
Comment
Question by:phillystyle123
  • 2
3 Comments
 
LVL 15

Expert Comment

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

Open in new window

0
 

Author Comment

by:phillystyle123
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):

http://ctemps.cjehost.com/subgallery_4column_with_test.php

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>";
	modalWindow.open();
};	
</script>
<script type="text/javascript">
 
function openModal(){
var returnVal = window.showModalDialog('modal.php');
window.location.href=returnVal;
 
}
 
</script>
 
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

0
 
LVL 15

Accepted Solution

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
key press alert 2 32
Make Session back to empty 9 30
What if i make webbased alternative for MS Access 5 67
Responsive Font Size 6 25
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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…

792 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