Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

closing a modal window that is already using close once

Posted on 2009-05-14
7
Medium Priority
?
452 Views
Last Modified: 2012-05-07
if you mouseover the 1st thumb here:

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

you'll see "close window" in the upper right corner - that works.

however i need the "back to the gallery" link underneath the picture to do the same thing and i can't get it to fly. there are two parts to this: 1:css and 2: js.

It looks like i need to create another close function that uses another close-window class like close-window2 or something. i've tried this but i can't get both to work.
js:
 
var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		$(".modal-window").remove();
		$(".modal-overlay").remove();
	},
	open:function()
	{
		var modal = "";
		modal += "<div class=\"modal-overlay\"></div>";
		modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
		modal += this.content;
		modal += "</div>";	
 
		$(this.parent).append(modal);
 
		$(".modal-window").append("<a class=\"close-window\"></a>");
		$(".close-window").click(function(){modalWindow.close();});
		$(".modal-overlay").click(function(){modalWindow.close();});
		
		
	}
};
 
css:
 
.close-window
{
position:absolute;
width:82px;
height:8px;
right:8px;
top:8px;
background:transparent url('../images/close-button.png') no-repeat scroll right top;
text-indent:-99999px;
overflow:hidden;
cursor:pointer;
opacity:.5;
filter: alpha(opacity=50);
-moz-opacity: 0.5;
}
.close-window:hover
{
opacity:.99;
filter: alpha(opacity=99);
-moz-opacity: 0.99;
}

Open in new window

0
Comment
Question by:phillystyle123
[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
  • 4
  • 2
7 Comments
 

Author Comment

by:phillystyle123
ID: 24391538
i've got the thing COMPLETELYstyled - i just need to figure out how to make the "back to the gallery" text close the window - currently just the "close widnow" png closes the window


var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		$(".modal-window").remove();
		$(".modal-overlay").remove();
	},
	open:function()
	{
		var modal = "";
		modal += "<div class=\"modal-overlay\"></div>";
		modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
		modal += this.content;
		modal += "</div>";	
 
		$(this.parent).append(modal);
 
		$(".modal-window").append("<a class=\"close-window\"></a>");
		$(".close-window").click(function(){modalWindow.close();});
		$(".modal-overlay").click(function(){modalWindow.close();});
		
		
	}
};

Open in new window

0
 

Author Comment

by:phillystyle123
ID: 24391546
oops -i need to create another block of code like this:


  $(".modal-window").append("<a class=\"close-window\"></a>");
                $(".close-window").click(function(){modalWindow.close();});
                $(".modal-overlay").click(function(){modalWindow.close();});
 call the class .close-window2 or something - i can't get it to work.

mouseover the 1st thumb on this page to see the modal window:
http://ctemps.cjehost.com/subgallery_4column_with_test.php#
0
 
LVL 18

Accepted Solution

by:
Pawel Witkowski earned 2000 total points
ID: 24394111
Well to be honest - using IFRAME in that solution what you need is kind strange, but I assume that you need this for something. So well what you need to do is to call  top.modalWindow.close()  when you click on   back to gallery

instead of:

<a onmousedown="window.returnValue = this.href;modalWindow.close();" href="http://www.google.com">back to gallery</a>

do:

<a onmousedown="window.returnValue = this.href;top.modalWindow.close();" href="http://www.google.com">back to gallery</a>



should be fine as long as both of pages are on one domain:)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:phillystyle123
ID: 24394303
so close!

mouseover the 1st thumb to get modal window:

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

the modal window now closes! which is one thing i need  - but i'm not being redirected to "detail_vertical.php" - fyi - i tried http://google.com here as well and i wasn't redirected - no error just the modal closes and that's it.
<a onmousedown="window.returnValue = this.href;top.modalWindow.close();" href="detail_vertical.php">view larger</a>

Open in new window

0
 
LVL 18

Expert Comment

by:Pawel Witkowski
ID: 24395301
have you tried    top.window   ?:)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24402432
How about

                                                              <a onclick="window.returnValue = this.href;top.modalWindow.close();" href="detail_vertical.php">view larger</a>
0
 

Author Closing Comment

by:phillystyle123
ID: 31581740
that's exactly what i ended up with - thanks!  i had a similar question open about this - but it was about closing the modal window and redirecting to another page here are both:

view larger | back to gallery      
0

Featured Post

Technology Partners: 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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…

597 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