Solved

closing a modal window that is already using close once

Posted on 2009-05-14
7
431 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
  • 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:
wilq32 earned 500 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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:wilq32
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

937 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

10 Experts available now in Live!

Get 1:1 Help Now