Solved

closing a modal window that is already using close once

Posted on 2009-05-14
7
428 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:phillystyle123
Comment Utility
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
Comment Utility
have you tried    top.window   ?:)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
How about

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

Author Closing Comment

by:phillystyle123
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
jQuery or CSS 9 37
JQuery & CSS Tab Issues 7 26
Python On Mouseover Save URL/Link 4 29
Problem to picture file 3 37
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

771 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