Hi, I have a nice little script that works well displaying images on
my website. It's a script where if you clik a thumbnail image a pop
up window opens that contains a larger version of the same image. What
I would like to create is a link that can be clicked on to close the
window that contains the larger image. This would make it easier for
the users to close the window. I have posted the script that I use.
Any help would be much appreciated. I tried to find the answer in the
archives and came close but in any programing language close usually
isnt good enough...Thanks .
"Head script"
<script language="JavaS cript">
<!--
function doNothing(){}
function popUp1(winFile, winHeight, winWidth) {
window.open(win File, '', 'width=' + winHeight + ',height=' + winWidth
+',')
}
// end -->
</script>
Image Link in body:
<p><a href="JavaScrip t: void doNothing()"
onClick="popUp1 ('images/P5210025.jpg',2 65,223)"><img
src="images/images1/P5210025_small. jpg" width="125" height="93"></a> 3 5192 th********@hotm ail.com (Steve) writes: Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same image.
So "works well" means that it works if no popup blocker prevents to
window from openening, and if Javascript is enabeled.
What I would like to create is a link that can be clicked on to close the window that contains the larger image.
Make it a button. Buttons are clicked for an effect. Links are clicked
to get to a new resource.
Where do you want the button placed, on the old page or the new?
This would make it easier for the users to close the window.
Depends on users. For me, using mouse gestures is faster than any
button. :)
Anyway, making it faster to close makes it sound like you want
the button on the popup page.
<script language="JavaS cript">
The type attribute is required in HTML 4, and the language attribute
is not necessary when type is used:
<script type="text/javascript">
<!--
HTML-like comments are not necessary in Javascript.
function doNothing(){}
??
function popUp1(winFile, winHeight, winWidth) { window.open(win File, '', 'width=' + winHeight + ',height=' + winWidth +',')
.... <p><a href="JavaScrip t: void doNothing()" onClick="popUp1 ('images/P5210025.jpg',2 65,223)"><img src="images/images1/P5210025_small. jpg" width="125" height="93"></a>
A good example of FAQ 4.24 <URL:http://jibbering.com/faq/#FAQ4_24>.
Your page is unusable in browsers without Javascript, and it doesn't
need to be.
Make the link:
<a href="images/P5210025.jpg"
onclick=popUp1( this.href,265,2 23);return false;"><img
src="images/images1/P5210025_small. jpg" width="125" height="93"></a>
This works with and without Javascript. With Javascript, you control the
opening of the window. Without, the user still sees the big image.
Now, to add a close button to the popup window, you need to control
the contents of the window. As it is now, you just open the image.
To make a close button, you need to open an html page. Try this:
---
function popUp1(winFile, winHeight, winWidth) {
var w = window.open('', '',
'width='+winHei ght+',height='+ winWidth+',resi zable=yes');
var d = w.document;
d.open();
d.writeln("<!DO CTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" "+
"\"http://www.w3.org/TR/html4/strict.dtd\">") ;
d.writeln("<htm l><head><title> Image<\/title>");
d.writeln("<met a http-equiv=\"Content-Script-Type\" ",
"content=\" text/javascript\"><\/head>");
d.writeln("<bod y style='margin:0 px;padding:0px; '>")
d.writeln("<div ><img src='"+winFile+ "' onclick='window .close()'><\/div>");
d.writeln("<\/body><\/html>");
d.close();
}
---
This opens a popup, just as before. Then it writes HTML into it,
making an img element. It sets the onclick on the image element to
close the window, so you can click anywhere in the window to close it
(faster than any button).
Good luck
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Thanks Lasse for your reply and the warning about the code not working
in all browsers. The "Close" link would go next to the thumbnail image
and not in the pop up window. This way the user would only have to
click the thumbnail to view/open the pictures and then close this
window quickly by clicking the link instead of having to move the
mouse over the "X". Thank you for you for your help!
p.s. sorry about not clarifying this the first time.
Lasse Reichstein Nielsen <lr*@hotpop.com > wrote in message news:<3c******* ***@hotpop.com> ... th********@hotm ail.com (Steve) writes:
Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same image.
So "works well" means that it works if no popup blocker prevents to window from openening, and if Javascript is enabeled.
What I would like to create is a link that can be clicked on to close the window that contains the larger image.
Make it a button. Buttons are clicked for an effect. Links are clicked to get to a new resource.
Where do you want the button placed, on the old page or the new?
This would make it easier for the users to close the window.
Depends on users. For me, using mouse gestures is faster than any button. :) Anyway, making it faster to close makes it sound like you want the button on the popup page.
<script language="JavaS cript">
The type attribute is required in HTML 4, and the language attribute is not necessary when type is used: <script type="text/javascript">
<!--
HTML-like comments are not necessary in Javascript.
function doNothing(){}
??
function popUp1(winFile, winHeight, winWidth) { window.open(win File, '', 'width=' + winHeight + ',height=' + winWidth +',') ... <p><a href="JavaScrip t: void doNothing()" onClick="popUp1 ('images/P5210025.jpg',2 65,223)"><img src="images/images1/P5210025_small. jpg" width="125" height="93"></a>
A good example of FAQ 4.24 <URL:http://jibbering.com/faq/#FAQ4_24>. Your page is unusable in browsers without Javascript, and it doesn't need to be.
Make the link: <a href="images/P5210025.jpg" onclick=popUp1( this.href,265,2 23);return false;"><img src="images/images1/P5210025_small. jpg" width="125" height="93"></a>
This works with and without Javascript. With Javascript, you control the opening of the window. Without, the user still sees the big image.
Now, to add a close button to the popup window, you need to control the contents of the window. As it is now, you just open the image. To make a close button, you need to open an html page. Try this:
--- function popUp1(winFile, winHeight, winWidth) { var w = window.open('', '', 'width='+winHei ght+',height='+ winWidth+',resi zable=yes'); var d = w.document; d.open(); d.writeln("<!DO CTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" "+ "\"http://www.w3.org/TR/html4/strict.dtd\">") ; d.writeln("<htm l><head><title> Image<\/title>"); d.writeln("<met a http-equiv=\"Content-Script-Type\" ", "content=\" text/javascript\"><\/head>"); d.writeln("<bod y style='margin:0 px;padding:0px; '>") d.writeln("<div ><img src='"+winFile+ "' onclick='window .close()'><\/div>"); d.writeln("<\/body><\/html>"); d.close(); } --- This opens a popup, just as before. Then it writes HTML into it, making an img element. It sets the onclick on the image element to close the window, so you can click anywhere in the window to close it (faster than any button).
Good luck /L th********@hotm ail.com (Steve) writes:
(Please don't top post! At least trim the quotes!) The "Close" link would go next to the thumbnail image and not in the pop up window.
Much easier then. The only problem is that you can't click it if the
popup obscures it, so you have to move the popup to get to the button.
Try:
<a href="imageURL. png"
onclick="openwi ndow = popUp1(this.hre f,'','width='.. ..);return false;">
<img src="thumbnailU RL.png"></a>
<input type="button" value="Close popup"
onclick="if(ope nwindow && !openwindow.clo sed) {
openwindow=open window.close(); }">
Inside popUp1, return the return value of the call to window.open.
That is the only reference you have to the new window, and you need
the reference in order to close the window.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.' This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: timmy_dale12 |
last post by:
I need help with this one. I have a function that pastes a row. In
each row i am pasting a link which is to call a date picker javascript
function. This is the code that pastes the link :
link = document.createElement('a');
link.href ="javascript:show_calendar('document.form1.date',document.form1.date.value);";
img = document.createElement('img');
img.setAttribute("src","H:Diverse\\cal.gif");
link.appendChild(img);
|
by: Johnny Knoxville |
last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works
fine if you add the site to favourites the normal way, but I have some
JavaScript code on a couple of pages with a link, which when you click it
bookmarks the site (much easier). The favicon is never saved if the site
is bookmarked this way. Does anyone have any ideas how to fix this??
This is the code:
<script language="JavaScript">
|
by: Derek |
last post by:
Hello:
I want to capture the event when a browser is closing, to give to the user
the posibility of close or no this browser. When the browser is closing,
this show a confirm window with two buttons: Accept and Cancel.
When press the Accept button, the browser is closing, and when press the
Cancel button, the browser isn´t closing.
I have tried with the event onunload, but this closes first the browser, and
|
by: bbass |
last post by:
thanks to all that replyied to my previous post with the following code
in question:
<a href="merc.htm" target="_new_merc" onfocusout=window.close
class="left_link">
i understand that the people don't like the idea of closing the browser
window because it's annoyance to the user
|
by: Rich |
last post by:
I have the following script on all pop up windows,
would like to have this work on all newer browsers if
possible. Right now it only works on MSIE & Opera.
Not sure why. Any suggestions are appreciated.
Not concerned with the print part yet. TIA Rich
<SCRIPT language="jscript">
function CloseWindow() {
self.close();
}
| |
by: adamurbas |
last post by:
ya so im pretty much a newb to this whole python thing... its pretty
cool but i just started today and im already having trouble. i
started to use a tutorial that i found somewhere and i followed the
instructions and couldnt get the correct results. heres the code
stuff...
temperature=input("what is the temperature of the spam?")
if temperature>50:
print "the salad is properly cooked."
else:
|
by: ojsimon |
last post by:
Hi
I found this script on a forum and have been trying to make it work, but all it returns is a blank screen, i tried using the debug error reporting but got nothing from that either just a blank page, here is the code<?php
//In this case, it fetches a search for "fresh content" from www.alltheweb.com, whom we hope you will visit.
$theLocation="http://www.alltheweb.com/search?cat=web&q=fresh+content&phrase=on&h=50";
//Below, at $start and...
|
by: sumanta123 |
last post by:
Dear All,
How will we do in JSP page on closing the parent window the child windows should close automatically.
I will show my code
Please i will show you my code.
For HTML link
function closeWin()
{
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |